How can I move between cells of a string grid in Delphi by tab or arrow keys? As you know, a string grid in delphi has only one tab order but I need to move between cells by arrow keys or tab to be more comfortable and user friendly .
I tried to use a KeyPress event, but this event only knows chars and doesn't know开发者_C百科 control keys like tab and ...
StringGrid.Options := StringGrid.Options + [goEditing, goTabs];
Or set this designtime.
Now you can move from cell to cell with tab and arrow keys. If you are actually editing a cell, then you have to release the focus first if you want to move to the cell to the left or right. In that case, use (shift) tab.
{ 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;
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论