当前位置:主页>Delphi教程>文章内容
DBGridEh实现单击标题栏排序方法
来源: 作者: 发布时间:2007-04-29  
 
1.添加引用:DBClient
2.置DBGridEh控件属性:
  设置dghAutoSortMarking属性为true
  设置希望排序的Column的TitleButton属性为true
3.//表格排序过程
procedure OrderGrid(dataSet:TClientDataset;orderField:string);
var
  i:integer;
begin
  if dataSet.IndexFieldNames<>'' then
  begin
    i:=TClientDataSet(DataSet).IndexDefs.IndexOf('i'+orderField);
    if i=-1 then
    begin
      with Dataset.IndexDefs.AddIndexDef do
      begin
        Name:='i'+orderField;
        Fields:=orderField;
        DescFields:=orderField;
      end;
    end;
    dataSet.IndexFieldNames:='';
    dataSet.IndexName:='i'+orderField;
  end
  else
  begin
    dataSet.IndexName:='';
    dataSet.IndexFieldNames:=orderfield;
  end;
end;
4.在DBGridEh的OnTitleClick事件中调用
OrderGrid(DM.ClientDataset,Column.FieldName);

 
上一篇:DBGridEh实现单击标题栏排序方法   下一篇:DLL、BPL与字符串传递
 
  相关文章
·DBGridEh实现单击标题栏排序方法
·DLL、BPL与字符串传递
·后台调用外部程序的完美实现(Delphi)
·DELPHI基础开发技巧
·利用VFI提高Delphi程序的重用性
·利用VFI提高Delphi程序的重用性
·DELPHI加注册表自启动的最简单代码
·ORLAND.DATA.ORACLE不匹配错误
·Delphi7中存储unicode的BUG
·模拟进程调度(delphi写的)
·Delphi数据库应用程序中常见错误
·最短路径(校园导游)的简单算法
 
【关闭窗口】
推荐本站资源
最新文章