简体   繁体   中英

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.

在此处输入图片说明

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.

在此处输入图片说明

在此处输入图片说明

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.

在此处输入图片说明


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?.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM