StringGrid Question lazarus / 31-LCL ---------------------------------------------------------------------- tintinux · 2011-07-07 15:16 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 ! Code: [Select]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; ---------------------------------------------------------------------- Blaazen · 2011-07-07 15:32 I just tried and it works as you wish (i.e. when I press Enter on the last row&col then row is added, first cell of the new row is focused and I can IMMEDIATELY write). So maybe there were some improvements in Grids.pas. (I use SVN - see below). ---------------------------------------------------------------------- Arbee · 2011-07-07 15:42 Tried this on Windows and there it does work too.  You can start typing text. Or is your problem that you do not see the caret (admittedly it only shows the focus rectangle), until you actually type the first character?  The caret does show when you first press enter in the new cell. ---------------------------------------------------------------------- Blaazen · 2011-07-07 15:59 BTW I see there a new option 'goAutoAddRows' . It automaticly adds a row if you press 'VK_DOWN' on the last row (and the last row is not empty). ---------------------------------------------------------------------- tintinux · 2011-07-09 06:43 Thanks for your replies. Yes, it works as expected in 0.9.30 Windows, but not in Linux Gtk2. I'll have to try to install 0.9.31 and pray Regards, Tintinux