StringGrid - change tab into return

Hi there,

How do you change the tab key into return in a TStringGrid.  I thought I might have been able to do it in the OnKeyDown event (if Key=VK_TAB then Key := VK_RETURN), but that didn't work.

It doesn't seem like the stringgrid is passed the tab press.

Any clues at all?

Many thanks,

Who is Participating?
MerijnBSr. Software EngineerCommented:
> What do you mean by which OnKeyDown event did I try?  The grid only has the one.

It's possible you had Form.KeyPreview set to true and grabbed the KeyDown event of the form.

For your problem:

The StringGrid has an options property, set goTabs to true. Now you will receive tab key presses in your grid's OnKeyDown event, which you can change.
MerijnBSr. Software EngineerCommented:
Which OnKeyDown event did you try? What behavior do you want to see if you press tab?
PAG_PromaxAuthor Commented:
At the moment when I press enter in the grid it cycles through the cells, moving from left to right, then down a row at the last column and starting from the first column again.  So, what I want is for this same behaviour to happen with the tab key.

What do you mean by which OnKeyDown event did I try?  The grid only has the one.
PAG_PromaxAuthor Commented:
You rule, MerijnB.  Thank you very much for what ended up being such a simple solution.  I didn't even know that option existed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.