Silver
Silver

Reputation: 193

Transparent background TStringGrid

The question is about creating a transparent background in the TStringGrid control. The idea was to modify the white color that is created by default in the grid and use a null color, but I have not succeeded. I share here what has been done so far.

enter image description here

After researching the issue, I was able to show some transperence in the StringGrid by modifying the opacity property, through "Edit Custum Style" in the Background section. This solution is not perfect because it affects the associated TScrollBox control, but at least it is a first approach.

enter image description here

enter image description here

Upvotes: 4

Views: 888

Answers (1)

Tom Brunberg
Tom Brunberg

Reputation: 21045

The design of the FMX TStringGrid has no property to make it transparent. However, using styles, transparency can be achieved. You don't need to use styles on the whole application if you don't want to, but you can if you do.

The solution is a simple setting in the style of the grid according to following:

Add a TStringGrid to an Fmx form

  • Right click the grid and select Edit Default style
  • The style editor opens. In structure select gridstyle - background - content
  • In the properties of content, locate ClipParent and set to True
  • Click on Apply and Close to close the style editor

You now have a grid where the area under the header is transparent. If you have more rows (default is 100) than fits, you will also have the scrollbar on the right.

You can remove the header by setting Options.Header = False in TStringGrid properties.

enter image description here


I just noticed that you have found some solution too, however relying on Opacity settings can be tricky, because it affects potentially also other parts of the grid, perhaps in your case, if you select the content and adjust its opacity?.

Upvotes: 3

Related Questions