我现在遇到了一个问题就是,要求:点击DBGrid的某一标题,然后按照此标题进行排序,并且此标题文字的后面出现向上的三角形符号,;再点击此标题,此标题文字的后面由向上的三角形符号变为向下的三角形符号。。但是,我现在就是不知道这个三角形的符号如何来实现?并且点击一次是向上的再点击为向下的。。请各位高手帮忙解决一下!!多谢了!!

解决方案 »

  1.   

    你可以用第三方控件,
    CXGRID,DXDBGRID 等
      

  2.   

    用enlib控件DBGridEh
    怎样使表格具有按title button排序的功能?
    在ucommon中添加
    procedure MakeDBGridEhSort(qry:TQuery;Column:TColumnEh);
    var
      i: Integer;
      strsql: string;
    begin
      //平,降,升,降,升
      if not qry.Active then
      begin
        exit;
      end;
      strsql:=qry.SQL.Text;
      i:= pos('order by', strsql);
      if i>0 then strsql:= copy(strsql, 1, i-1);
      case Column.Title.SortMarker of
        smUpEh: begin
          strsql:= strsql + ' order by ' + Column.FieldName + ' DESC';
        end;
        smDownEh: begin
          strsql:= strsql + ' order by ' + Column.FieldName + ' ASC';
        end;
        smNoneEh: begin
          strsql:= strsql + ' order by ' + Column.FieldName + ' DESC';
        end;
      end;
      with qry do
      begin
        Active:= False;
        SQL.Clear;
        SQL.Add(strsql);
        Active:= True;
      end;    // with
    end;
    双击表格,把TDBGridEh对象中各个button的title|titlebutton属性设为true
    选中表格,添加OnTitleBtnClick事件,在其中添加
    ucommon.MakeDBGridEhSort(DM.qryCJGL,Column);
      

  3.   

    用dbgridEh好像不要编写一条代码吧,我记得好像没有写过代码,设置几个属性就行了。
      

  4.   

    http://community.csdn.net/Expert/topic/3704/3704611.xml?temp=.5381891
      

  5.   

    我试验的结果表明,DBGridEh只能帮我们把小三角显式出来,不能帮我们排序。
      

  6.   


    将Optioneh.dghAutosorting:=true;这样就不用写代码就能实现排序了吗????请指教我没有用过这个
      

  7.   

    安装Ehlib包的时候好像还要加上ehlibXXX.pas,XXX为你使用的数据集,如果为clientdatasource则为EhlibCDS.pas。我记得如果使用Ehlib的过滤功能,要加上的。请仔细阅读一下Ehlib的文档。