Hi
After I press RETURN in the last cell of the last row of the grid, I would like to create a new row and go to the first column of it, to go on entry.
The code below does most of the job, BUT after I selected the wanted cell, I have no caret and no focus. I must click with the mouse to be able to enter something and go on.
Anybody knows what I must do to get the focus in the cell, allowing to enter data only with the keyboard ?
I'm using 0.9.30 on Linux. Options of the StringGrid are : AlwaysShowEditor, Editing, DrawFocusSelected.
Thanks for your help !
procedure Tform1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
Var
R, C : integer ;
begin
case Key of
VK_RETURN, VK_TAB :
begin
C := StringGrid1.Col ;
R := StringGrid1.Row;
if (R = StringGrid1.RowCount-1) and (C = StringGrid1.ColCount-1) then
begin
Key := VK_Unknown ;
StringGrid1.RowCount := StringGrid1.RowCount+1 ;
StringGrid1.Col := 0 ;
StringGrid1.Row := R+1 ;
end;
end;
end;
end;