Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

StringGrid editing problem

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
Marco Gasi
Asked:
Marco Gasi
1 Solution
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
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
 
Marco GasiFreelancerAuthor Commented:
Many thanks for your help. On to the next.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now