FMXTStringGridBackgroundColor (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

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:

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

StrigGridBackgroundColorInital.png

StrigGridBackgroundColorChanged.png

Uses