请问如何在按住Ctrl键的时假实现对DBgrid的多选,最好能给出代码

解决方案 »

  1.   

    将DBGrid的Options属性下的dgMultiSelect设为True即可!
      

  2.   

    当然了,你认为有多复杂。关于多选delphi帮助中还带了一个Example
      

  3.   

    将DBGrid的Options属性下的dgMultiSelect设为True
      

  4.   

    //==============================================================================
    //全选DBGrid中所有数据**********************************************************
    //==============================================================================
    procedure DBGridSelectAll(DBGrid: TDBGrid);
    var SavePlace: TBook;
    begin
      with DBGrid do
      begin//01
        if (dgMultiSelect in Options) and DataSource.DataSet.Active then
        with DataSource.Dataset do
        begin//02
          if (BOF and EOF) then Exit;
          DisableControls;
          try
            SavePlace := GetBook;
            try
              First;
              while not EOF do
              begin//03
                SelectedRows.CurrentRowSelected := True;
                Next;
              end;//03
            finally
              try
                GotoBook(SavePlace);
              except
              end;
              FreeBook(SavePlace);
            end;
          finally
            EnableControls;
          end;
        end;//02
      end;//01
    end;
      

  5.   

    不过DBGRID还不能实现按住SHIFT,一次性选中多个,如果想要实现这个功能 的话,可以考虑使用IP POWER3000中的TWWDBGRID
      

  6.   

    按住Shift选中多个要自己写代码咯
      

  7.   

    将DBGrid的Options属性下的dgMultiSelect设为True即可!