It it possible with TStringGrid when you write data in a cell
and you press enter the program is going to the next row?
Thanx Bruun
In article <8i64p1$8g...@bornews.borland.com>, wrote:
>
> How do make the enter key act like tab in TStringGrid?
Handle the grids OnKeyDown event:
Handling enter like tab in a string grid:
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key = VK_RETURN Then begin
With Sender As TStringGrid Do begin
If Col < (ColCount-1) Then
Col := Col+1
Else Begin
Col := FixedCols;
If Row < (RowCount -1 ) Then
Row := Row+1
Else
Row := Fixedrows;
End;
End;
Key := 0;
end;
end;
Another option would be to fabricate a genuine tab key event:
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key = VK_RETURN Then begin
keybd_event( VK_TAB, MapVirtualKey( VK_TAB,0), 0, 0);
keybd_event( VK_TAB, MapVirtualKey( VK_TAB,0), KEYEVENTF_KEYUP, 0);
Key := 0;
end;
end;
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
In article <3957a050@dnews>,
Sent via Deja.com http://www.deja.com/
Before you buy.
handle the stringgrids OnKeyDown event.
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key = VK_RETURN Then begin
With Sender As TStringGrid Do begin
If Row < (RowCount -1 ) Then
Row := Row+1
Else
Row := Fixedrows;
End;