用adoconnection,adoquery,datasourse,dbgrid这几个控件,数据库为SQL 2000 
我想对对DBGRID中的数据做一个类似于EXCEL的筛选功能...
不知道能否实现

解决方案 »

  1.   

    可以自己做下拉选择,第三方有现成的,dxdbgrid就有类似excel的下拉筛选
      

  2.   

    下載個DEV系列的控件,用CXGRID就解決了。
      

  3.   

    我下载了个dxdbgrid.dll
    不知该怎么使用...
    新人,刚学DELPHI
      

  4.   

    dxdbgrid.dll 没用,到delphibox.com中下载安装包
      

  5.   

    上面控件标签,往后找,有dev开头的
      

  6.   

    找不到dev开头的,估计安装的不对...
    之前下载过几个安装包,装完了都找不到,郁闷ing
      

  7.   

    可以自己写一个Procedure Terp.sx1(component:string;form:string);
    var i:integer;
    begin
     with  application.FindComponent(form) as tform  do
     begin
     //当选中的字段是STRING类型时
    // if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftMemo) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftFixedChar) then
     if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftMemo) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftFixedChar) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftwidestring) then
      begin
      If Application.findcomponent('zdsx')=nil Then
      Application.CreateForm(Tzdsx, zdsx);
       If Application.findcomponent('rqsx')=nil Then
      Application.CreateForm(Trqsx, rqsx);
     for i:=0 to tdbgrideh(FindComponent(component)).Columns.Count-1 do
     begin
       if tdbgrideh(FindComponent(component)).Columns[i].FieldName=tdbgrideh(FindComponent(component)).SelectedField.FieldName then
       begin
         if pos('期',tdbgrideh(FindComponent(component)).Columns[i].Title.Caption)>0 then
         begin
         rqsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
         rqsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
         rqsx.Label2.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
         zdsx.Release;
         rqsx.show;
         end
         else
         begin
         zdsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
         zdsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
         rqsx.Release;
         zdsx.show;
         end;
         exit;
       end;
     end;
    end;
    //当选中的字段是日期型时
    if tdbgrideh(FindComponent(component)).SelectedField.DataType=ftdatetime then
    begin
    If Application.findcomponent('sjsx')=nil Then
     Application.CreateForm(Tsjsx, sjsx);
      sjsx.show;
     for i:=0 to tdbgrideh(FindComponent(component)).Columns.Count-1 do
     begin
       if tdbgrideh(FindComponent(component)).Columns[i].FieldName=tdbgrideh(FindComponent(component)).SelectedField.FieldName then
       begin
       sjsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
       sjsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       sjsx.Label2.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       exit;
       end;
     end;
     end;
    //当选中的字段是数值型浮点或整型时
     //数值型字段
    if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftfloat) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftinteger) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftbcd)then
    begin
    If Application.findcomponent('szsx')=nil Then
     Application.CreateForm(Tszsx, szsx);
      szsx.show;
     for i:=0 to tdbgrideh(FindComponent(component)).Columns.Count-1 do
     begin
       if tdbgrideh(FindComponent(component)).Columns[i].FieldName=tdbgrideh(FindComponent(component)).SelectedField.FieldName then
       begin
       szsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
       szsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       szsx.Label2.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       exit;
       end;
     end;
     end;
     end;
    erp.sx1(ActiveControl.Name,'nxddxh');
    dqform:='nxddxh';
    dqkj:=ActiveControl.Name;
      

  8.   

    可以自己做一个
    Procedure Terp.sx1(component:string;form:string);
    var i:integer;
    begin
     with  application.FindComponent(form) as tform  do
     begin
     //当选中的字段是STRING类型时
    // if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftMemo) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftFixedChar) then
     if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftstring) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftMemo) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftFixedChar) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftwidestring) then
      begin
      If Application.findcomponent('zdsx')=nil Then
      Application.CreateForm(Tzdsx, zdsx);
       If Application.findcomponent('rqsx')=nil Then
      Application.CreateForm(Trqsx, rqsx);
     for i:=0 to tdbgrideh(FindComponent(component)).Columns.Count-1 do
     begin
       if tdbgrideh(FindComponent(component)).Columns[i].FieldName=tdbgrideh(FindComponent(component)).SelectedField.FieldName then
       begin
         if pos('期',tdbgrideh(FindComponent(component)).Columns[i].Title.Caption)>0 then
         begin
         rqsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
         rqsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
         rqsx.Label2.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
         zdsx.Release;
         rqsx.show;
         end
         else
         begin
         zdsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
         zdsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
         rqsx.Release;
         zdsx.show;
         end;
         exit;
       end;
     end;
    end;
    //当选中的字段是日期型时
    if tdbgrideh(FindComponent(component)).SelectedField.DataType=ftdatetime then
    begin
    If Application.findcomponent('sjsx')=nil Then
     Application.CreateForm(Tsjsx, sjsx);
      sjsx.show;
     for i:=0 to tdbgrideh(FindComponent(component)).Columns.Count-1 do
     begin
       if tdbgrideh(FindComponent(component)).Columns[i].FieldName=tdbgrideh(FindComponent(component)).SelectedField.FieldName then
       begin
       sjsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
       sjsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       sjsx.Label2.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       exit;
       end;
     end;
     end;
    //当选中的字段是数值型浮点或整型时
     //数值型字段
    if (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftfloat) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftinteger) or (tdbgrideh(FindComponent(component)).SelectedField.DataType=ftbcd)then
    begin
    If Application.findcomponent('szsx')=nil Then
     Application.CreateForm(Tszsx, szsx);
      szsx.show;
     for i:=0 to tdbgrideh(FindComponent(component)).Columns.Count-1 do
     begin
       if tdbgrideh(FindComponent(component)).Columns[i].FieldName=tdbgrideh(FindComponent(component)).SelectedField.FieldName then
       begin
       szsx.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption;
       szsx.Label1.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       szsx.Label2.Caption:=tdbgrideh(FindComponent(component)).Columns[i].Title.Caption+':';
       exit;
       end;
     end;
     end;
     end;erp.sx1(ActiveControl.Name,'nxddxh');
    dqform:='nxddxh';
    dqkj:=ActiveControl.Name;
      

  9.   

    终于安装好了,不知道cxgrid如何使用...
    谁能提供一下示例...谢谢!
      

  10.   

    用EhLib控件可以解决你的问题的,也是比较方便的,但我一直没有研究通当为UNLL时为何出错,但是EhLib的demo中是不会出错的!