How to set a TStringgrid into editing mode at runtime by a buttonclick?

Hi Folks!

I think the title is quite selfexplanatory if not let me know!

Regards Peter

(working sample will do the trick and it would be great if you would comment what you do)
PeterdeBAsked:
Who is Participating?
 
mikelittlewoodConnect With a Mentor Commented:
o hang on .. do you mean altering the options of the stringgrid?

StringGrid1.Options := [goEditing]

dont forget to include all the other options that are needed

ON:
StringGrid1.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing]
OFF:
StringGrid1.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect]
0
 
mikelittlewoodCommented:
A Stringgrid is editable anytime (unless you set the enabled property to false)
You just have to know what row and column is currently selected, or what you want to update, and use the cells[icol,irow] := 'value' to change something
0
 
BlackTigerXCommented:
set the goEditing option as mikelittlewood suggested, then on the button Onclick event put:

  StringGrid1.SetFocus;
  StringGrid1.EditorMode:=True
0
 
BlackTigerXCommented:
you can use this on the Forms OnCreate event to allow editing at run-time

procedure TForm1.FormCreate(Sender: TObject);
begin
  StringGrid1.Options:=StringGrid1.Options+[goEditing]
end;
0
 
PeterdeBAuthor Commented:
Perfect!

Tnx for responding guys!

Regards Peter
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.