ehlib试试

解决方案 »

  1.   

    dbgrideh配合他的内存表和cxgrid都有这功能
      

  2.   

    CxGrid      
      

  3.   

    dbgrideh和cxgrid都有这功能,同时DBGrid也能做,但比较复杂。dbgrideh的做法: 
    1、uses EhLibAdo;(如果客户端用ADO控件);
    2、设置DBGridEh的Column的TitleButton属性为True;
    3、设置DBGridEh的OptionsEh的dghAutoSortMarking的属性为True; 
    4、设置DBGridEh的SortLocal属性为True 。 
      

  4.   

    dbgrideh的做法: 
    1、uses EhLibAdo;(如果客户端用ADO控件);
    这怎么理解,我试了下面那几步,只出来了升降序
      

  5.   

    一、排序功能:
    首先在uses节中根据你选用的数据集引用对应的 EhLibXXX (EhLibADO, EhLibCDS…)
    然后再设置下面几个DBGridEh控件的属性:
    procedure TForm1.FormCreate(Sender: TObject);
    var
      I: Integer;
    begin
      DBGridEh1.SortLocal := True;
      DBGridEh1.OptionsEh := DBGridEh1.OptionsEh + [dghAutoSortMarking];
      for I := 0 to DBGridEh1.Columns.Count - 1 do
        DBGridEh1.Columns[I].Title.TitleButton := True;
    end;procedure TForm1.FormCreate(Sender: TObject);
    var  I: Integer;
    begin
      DBGridEh1.SortLocal := True;
      DBGridEh1.OptionsEh := DBGridEh1.OptionsEh + [dghAutoSortMarking];
      for I := 0 to DBGridEh1.Columns.Count - 1 do
        DBGridEh1.Columns[I].Title.TitleButton := True;
    end;二、过滤功能:
    具体设置很简单,如下:
      DBGridEh1.STFilter.Visible := True;
      DBGridEh1.STFilter.Local := True;
      DBGridEh1.STFilter.Visible := True;  DBGridEh1.STFilter.Local := True;如果想在下拉列表中加入自定义过滤条件,可以在相应列的OnFillSTFilterListValues事件中加入:procedure TForm3.DBGridEh1Columns1FillSTFilterListValues(  Sender: TCustomDBGridEh;
                                Column: TColumnEh; Items: TStrings;  var Processed: Boolean);
    begin
      Items.Add('201201');
      Items.Add('201202');
      Items.Add('201203');
      Items.Add('201204');
    end;三、自动搜索:
    该搜索框可实现自动搜索并过滤。
      Delphi/Pascal  DBGridEh1.SearchPanel.Enabled := True;
      DBGridEh1.SearchPanel.FilterOnTyping := True; //实时过滤
      DBGridEh1.SearchPanel.Enabled := True;  DBGridEh1.SearchPanel.FilterOnTyping := True; //实时过滤