StringGrid - change tab into return

Posted on 2009-02-19
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,

Question by:PAG_Promax
    LVL 19

    Expert Comment

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

    Author Comment

    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.
    LVL 19

    Accepted Solution

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

    Author Closing Comment

    You rule, MerijnB.  Thank you very much for what ended up being such a simple solution.  I didn't even know that option existed.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now