Hi,
I have a TMSFMXLiveGrid. I set up ColumnType as ctButton for a column. I can see I have a button and a text showing in cells at that column. My question is how I can access this button and change the text of the button. I found a demo code to do that through GetCellProperties event like this:
procedure TForm719.TMSFMXGrid1GetCellProperties(Sender: TObject; ACol,
ARow: Integer; Cell: TFmxObject);
begin
if Cell is TTMSFMXButtonGridCell then
begin
(cell as TTMSFMXButtonGridCell).Button.Text := 'X';
end;
end;
How do I do in C++ builder? How do I compare "if Cell is TTMSFMXButtonGridCell " in C++? For the second statement " (cell as TTMSFMXButtonGridCell)", can I just cast the pointer to get the access?
Thanks!
Gene.
Hi,
You can use the following code to check the type of the cell and convert it:
void __fastcall TForm1::TMSFMXGrid1GetCellProperties(TObject Sender, int ACol, int ARow,
TFmxObject Cell)
{
if (Cell->ClassType() == __classid(TTMSFMXButtonGridCell)) {
TTMSFMXButtonGridCell btn = (TTMSFMXButtonGridCell) Cell;
}
}
Kind Regards,
Pieter
That works! I got an access to that button and I am able to reset the text to the button.
I have another question about the textsettings. I tried to change the text size and style using these:
btn->Button->TextSettings->Font->Size=28;
btn->Button->TextSettings->Font->Style<<fsBold;
They don't work. What I should do to do that?
Thanks!
Gene.
Hi,
You need to remove the styledsettings option set
Button1->TextSettings->Font->Size = 28;
Button1->StyledSettings = TStyledSettings();
Kind Regards,
Pieter
It works! Thanks!