Solved

How to retrieve text from TStringGrid when select it

Posted on 2008-06-22
2
1,246 Views
Last Modified: 2010-04-21
I have a stringgrid named 'Sg1'

It has 6 columns and many rows depending on data loaded into it.  I need to be able to click any cell in column 0 and have the text returned as a string.
For eg:

Title                        Genre                     Actor(1)                    Actor(2)                  Actor(3)                  Location                    Mad Max                Action                     Mel Gibson               Tina Turner                                              Home

I have the top row fixed and the next row(s) has the data in them.  I need to be able to click on any cell in Col(0) the title column and have delphi return a string of the text that is in that cell.  So if a user clicks on cells[0,5] it will show me/them the text in that cell but if they click on cells[1,5] it will not do anything.  I only need col '0' to be active.

Thanks in advance
0
Comment
Question by:Mark Brady
2 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 100 total points
ID: 21840376
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
  if StringGrid1.Col = 0 then
    Label1.Caption := StringGrid1.Cells[0,StringGrid1.Row];
end;
0
 
LVL 20

Author Closing Comment

by:Mark Brady
ID: 31469522
I can't believe it was that wasy.  Thanks Mokule !
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 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

19 Experts available now in Live!

Get 1:1 Help Now