We help IT Professionals succeed at work.

StringGrid - change tab into return

PAG_Promax
PAG_Promax asked
on
Medium Priority
507 Views
Last Modified: 2013-11-23
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,

Stu.
Comment
Watch Question

MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
Which OnKeyDown event did you try? What behavior do you want to see if you press tab?

Author

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.
Sr. Software Engineer
CERTIFIED EXPERT
Commented:
> 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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.