怎样控制键盘对dbgrid的控制?我在插入记录时,只能让它在这一行移动,该怎么做?
如果有对应的控件在哪里下呀?谢谢了

解决方案 »

  1.   

    在DBGRID的OnKeyDown事件中:
    procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if DBGrid1.DataSource.State = dsInsert then
        if Key in [VK_DOWN, VK_UP] then Key := 0;
    end;
      

  2.   

    我也觉得应该通过keydown事件来控制
    或者把dbgrid.datasource.aotoedit:=false;
      

  3.   

    在DBGRID的OnKeyDown事件中:
    procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if DBGrid1.DataSource.State = dsInsert then
        if Key in [VK_DOWN, VK_UP] then Key := 0;
    end;