TStringGrid: How to move to next column hitting the enter key?? lazarus / 31-LCL ---------------------------------------------------------------------- jshand2010 · 2013-05-24 21:54 i have just entered a new cell and put info in that cell, how do i move to the next cell to the right by pressing the enter key?? thanks guys? ---------------------------------------------------------------------- Blaazen · 2013-05-24 22:12 If you have [goEditing] in Options then property AutoAdvance := aaRight will do the job (it is default). If you don't use goEditing, you will have to manage it yourself in OnKeyDown or OnKeyUp event. I don't know if StringGrid has some special public method for this but it is easy: Code: [Select]if Key = VK_RETURN then   with (Sender as TStringGrid) do     Col := Col + 1;+ skip to next row somehow. ---------------------------------------------------------------------- jshand2010 · 2013-05-24 22:27 hi there, i actually found this worked: procedure Tfproductmanager.sgKeyPress(Sender: TObject; var Key: char); begin   if (Key=#13) then begin     with (Sender as TStringGrid) do begin       col:=col+1;     end;   end; end; and i also diabled the goRowSelect as well thanks heaps ---------------------------------------------------------------------- Bart · 2013-05-25 10:44 Quote from: jshand2010 on May 25, 2013, 12:27:48 amprocedure Tfproductmanager.sgKeyPress(Sender: TObject; var Key: char); begin   if (Key=#13) then begin     with (Sender as TStringGrid) do begin       col:=col+1;     end;   end; end; This will crash on right most column. AutoAdvance is specifically made for this purpose. No need to re- invent the wheel (and introduce new bugs). Bart ---------------------------------------------------------------------- Blaazen · 2013-05-25 11:19 @ Bart I tested and it never crash on right most column (no matter if it is a classic grid or grid made of columns). The AutoAdvance does not work on readonly grid (i.e. when goEditing is False - I don't know if jshand2010 has readonly grid or not). I tested with Laz. trunk. ---------------------------------------------------------------------- Bart · 2013-05-25 17:01 Quote from: Blaazen on May 25, 2013, 01:19:58 pm@ Bart I tested and it never crash on right most column (no matter if it is a classic grid or grid made of columns). Hey, that's unexpected... Quote from: Blaazen on May 25, 2013, 01:19:58 pmThe AutoAdvance does not work on readonly grid Yes, that's a valid comment. Did not think of that. Bart