FMXTStringGridBackgroundColor (Delphi)
Description
This example shows how to change the background color of a TStringGrid without using the Style Designer dialog.
To build and test this example:
- Create a Multi-Device Application - Delphi.
- Add a TStringGrid and a TColorComboBox.
Code
Add the following code to the OnChange event handler of the TColorComboBox.
procedure TForm1.ColorComboBox1Change(Sender: TObject);
var r : TRectangle;
begin
//Identifies the TRectangle that serves as background for the TStringGrid.
r:=StringGrid1.FindStyleResource('background') as TRectangle;
//Changes the color.
if Assigned(r) then
r.Fill.Color:=ColorComboBox1.Color;
end;
Default background color | Changed background color |
---|---|
Uses
- TStyledControl.FindStyleResource ( fr | de | ja )