当dbgrideh的一个单元格处于编辑状态(光标闪烁)时,如何按方向键到左右的单元格?

解决方案 »

  1.   

    研究研究这个例子
    DBGrid1KeyPress(Sender: TObject; var Key: Char)
    begin
    if Key = #13 then                              //回车键
      begin
        if not (ActiveControl is TDBGrid) then
        begin
          Key := #0;                                 // eat enter key
          Perform(WM_NEXTDLGCTL, 0, 0);              // move to next control
        end
        else if (ActiveControl is TDBGrid) then      // if it is a TDBGrid
        with TDBGrid(ActiveControl) do
        if selectedindex < (fieldcount -1) then  // increment the field
        selectedindex := selectedindex +1
        else
        selectedindex := 0;
      end;
    end;