Delphi: move between grid cells

How can I navigate between cells in a grid of rows in Delphi by tab or arrow keys? As you know, the grid of rows in delphi has only one tab order, but I need to move between cells using the arrow keys or the tab so that they are more convenient and user-friendly.

I tried to use the KeyPress event, but this event knows only characters and does not know control keys such as tab and ...

+5
source share
2 answers
StringGrid.Options := StringGrid.Options + [goEditing, goTabs];

Or set this development time.

. , , . (shift).

+5
{ This handles arrow left and right in the GRID
}
procedure TJournalForm.JournalGridKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);

begin
    if (JournalGrid.EditorMode = True) then      //  if arrowing while editing…
      begin
           if Key=VK_Left then if JournalGrid.Col>(JournalGrid.FixedCols+1) then JournalGrid.Col:=JournalGrid.Col-1;
         if Key=VK_Right then if JournalGrid.Col<(JournalGrid.ColCount-1) then JournalGrid.Col:=JournalGrid.Col+1;
    end;
end;
0

All Articles