Hello
I am trying to set up a grid with a column of buttons that all have an edEditBtn editor type. I am able to get the edit buttons to show up, but I cannot seem to change the width of the edit button. I have attached a simplified demo project with some test code that reproduces the issue.
How can I configure the grid so that I can change the width of the edit button?
EditBtnDemo.zip (22.8 KB)
Thanks,
Jake
Hi!
When the BtnEdit is not in edit mode, the button will always get the width set in AdvStringGrid1.ControlLook.DropDownButtonWidth + 2. It's default value is 16.
If you had checked the goEditing option of your grid, you'd see that when you enter in edit mode your button is shown with the width you wanted. Altough your editting was not enabled, one could click the side button and get back your 'ellipsis clicked' messagebox.
Yes, the GetEditorProps is called for column 2, but the width you've set would only take effect in edit mode. The proof that it is called is that your buttons take the caption you've set.
You could have set them in GetEditorType too.
Indeed, you could set DropDownButtonWidth at grid level, but this is awful. It would be the default display button width for many other controls with a side-button that could appear in your grid.
Maybe you should think about using a larger button in a distinct column, or use FNCDataGrid that allows you to place a customized button in any cell in spite of it's editor.
grid.ControlLook.DropDownButtonWidth is the setting to control the button width both in edit mode and display mode.
When you want to change only in edit mode, use grid.OnGetEditorProp and set it via:
procedure TForm1.AdvStringGrid1GetEditorProp(Sender: TObject; ACol,
ARow: Integer; AEditLink: TEditLink);
begin
AdvStringGrid1.BtnEdit.Button.Width := editwidth;
end;
By checking the sample provided, seems like he wants to see the buttons with Width = 100 even if not in edit mode.
Just that goEditing was not enabled, and the column widths were less than 100.
BtnEdit.Button.Width and/or BtnEdit.ButtonWidth (when you set ButtonWidth it also sets FButton.Width) are being used when the cell editor is activated, in spite of DropDownButtonWidth value.
OnGetEditorProp is indeed a way to override the default setting DropDownButtonWidth for editing
Thank you both for your replies. Using AdvStringGrid1.ControlLook.DropDownButtonWidth will work for what I am trying to do. I will review the other suggested approaches to see if I can apply them in future updates.