Solved

StringGrid editing problem

Posted on 2011-09-05
2
457 Views
Last Modified: 2012-05-12
Hi all.
I have a StringGrid with two columns: in the first one there is a checkbox in the other one an empty string. I wish user be able to edit the second field only if the checkbox in the same row is checked. In other words, I have to make editable only one cell, not entire column.

Any idea?

Thanks in advance for your help.
0
Comment
Question by:Marco Gasi
2 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 36484356
You could try this (make the cell editable just if the checkbox is checked)
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
begin
  StringGrid1.Options := StringGrid1.Options - [goEditing];
  if StringGrid1.Objects[ACol-1, ARow] <> nil then
    if StringGrid1.Objects[ACol-1, ARow] is TCheckBox then
      if (StringGrid1.Objects[ACol-1, ARow] as TCheckBox).Checked then
        StringGrid1.Options := StringGrid1.Options + [goEditing]
end;

Open in new window

0
 
LVL 31

Author Closing Comment

by:Marco Gasi
ID: 36484510
Many thanks for your help. On to the next.
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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

14 Experts available now in Live!

Get 1:1 Help Now