TTMSFMXGrid and GetCellEditorType

I want my grid to have a button in the editing field.
So I implemented the GetCellEditorType.

procedure TForm1.TMSFMXGrid1GetCellEditorType(Sender: TObject; ACol, ARow: Integer; var CellEditorType: TTMSFMXGridEditorType);
begin
  CellEditorType := etEditBtn;
end;

How can I detect that the Button in the Edit field has been pressed ?
Can I place a specific Text or Image on the button in the Edit field ?

Thanks for any suggestions... 

Hi, 


You can assign an event to the button with
TMSFMXGrid1.CellEditBtn.OnButtonClick := ButtonClick;

Hi Pieter,

Works just fine, thanks.


Can I set more properties this way ?
I tried to set the text for the button and the width, but that didn't seem to work.
TMSFMXGrid1.CellEditBtn.Text := 'MyText';
TMSFMXGrid1.CellEditBtn.Width := 120;

Hi,



You should normally be able to access the button property, now you are accessing the properties for the edit itself.

Hi Pieter,


You are so right.
But I tried to access the Button itself by using:
TMSFMXGrid1.CellEditBtn.Button
But the Button is always NIL.

Do you have an example for me ?
Preferably when setting properties Text, Width and Bitmap for the Button.

Thanks in advance.

The buttton is part of a style and the style is only loaded when the button has a parent. To change properties of the button you need to use the OnApplyStyleLookup event:


procedure TForm1.ApplyEditStyleLookup(Sender: TObject);
begin
  TMSFMXGrid1.CellEditBtn.Button.Width := 40;
  TMSFMXGrid1.CellEditBtn.ButtonBitmap.Bitmap.LoadFromFile('MyImage.png');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFMXGrid1.CellEditBtn.OnApplyStyleLookup := ApplyEditStyleLookup;
end;


Thanks Pieter, it works...


Is there a way to change these settings depending on the Selected Column/Row ?

Yes, you can move the code inside the OnGetCellEditorProperties event.