StringGrid中怎么控制回车键:回车后光标的移动!平移一格还是下移一格!

解决方案 »

  1.   

    StringGrid内如何回车换单元格?procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      If Key = Word(#13) Then Begin
        If StringGrid1.Col < StringGrid1.ColCount-1 Then
          StringGrid1.Col := StringGrid1.Col+1
        Else Begin
          StringGrid1.Col := StringGrid1.FixedCols ;
          If StringGrid1.Row < StringGrid1.RowCount-1  Then
            StringGrid1.Row := StringGrid1.Row+1 ;
        End;
      End;
    end;