Extracting highlighted text from TStringGrid Inplace Editor

Posted on 2005-04-14
Last Modified: 2010-04-05
When you activate the inplace text editor for a string grid you are able to do use the mouse to highlight all or part of the character string. I want to be able to retrieve just the highlighted portion of the inplace editor text  string.
Question by:rfedyk
    LVL 1

    Accepted Solution

    In the absence of a better solution you may want to consider the following, yes it is very sloppy way of doing it, but I am open to a better one??

    example uses TStringGrid or whatever grid you wish I guess and puts the selected cell text into a TEdit...

            windows.keybd_event(VK_CONTROL, VK_CONTROL,0,0);
            windows.keybd_event(ord('C'), ord('C'),0,0); //C
            windows.keybd_event(ord('C'), ord('C'),KEYEVENTF_KEYUP,0); //C
            windows.keybd_event(VK_CONTROL, VK_CONTROL,KEYEVENTF_KEYUP,0);
            edit1.text := '';

    Hope this helps! was a tricky one.
    Justin Willis.
    LVL 1

    Author Comment


    Many thanks. That works just fine except for the StringGrid1.SetFocus. That actually removes the focus from the inplace editor.

    Roger Fedyk
    LVL 1

    Expert Comment

    Strange, must be becuase I was using a TButton to trigger the code, which of coarse gives the button focus when the code runs.  Keep in mind though that although the code executes very quickly there may be a small window in which another application does something with the clipboard to mess things up, but I can't think of a better way, should be fine..


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    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

    16 Experts available now in Live!

    Get 1:1 Help Now