stringgrid,如何在回车后把焦点定位在下列的单元格上?

解决方案 »

  1.   

    在onpress 事件中
    if key=#13 then 
    stringgrid.col:=stringgrid.col+1;
      

  2.   

    procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
    begin
    if key=#13 then
    stringgrid1.Perform(WM_KEYDOWN, VK_DOWN,0);
    end;
      

  3.   

    procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
    begin  if Key = #13 then
        with StringGrid1 do
          if Col < ColCount-1 then {next column!}
            Col := Col + 1
          else if Row < RowCount-1 then begin {next Row!}
            Row := Row + 1;
            Col := 1;
          end else begin {End of Grid! - Go to Top again!}
            Row := 1;
            Col := 1;
            {or you can make it move to another Control}
          end;
    end;