Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TStringGrid

0 views
Skip to first unread message

Bruun Jongbloed

unread,
Jun 26, 2000, 3:00:00 AM6/26/00
to
Hello,

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

Eliza

unread,
Jun 26, 2000, 3:00:00 AM6/26/00
to
This is an article I found on this forum by typing 'string grid' into
the search box. Using the code below, and add to it the code to add row:
rowcount := rowcount + 1 when the row = rowcount-1

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.

Peter Below (TeamB)

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to
In article <3957a050@dnews>, Bruun Jongbloed wrote:
> It it possible with TStringGrid when you write data in a cell
> and you press enter the program is going to the next row?
>
Bruun,

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;

0 new messages