Transparent background TStringGrid

主宰稳场 提交于 2019-12-10 17:34:23

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/59086807/transparent-background-tstringgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!