Search code examples
delphitab-ordering

delphi : move between cells of string grid


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 control keys like tab and ...


Solution

  • 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.