How to achieve transparent BackColor on a WinForms source control?

I'm about to lose my mind here. Why doesn't the checkbox control mix with what's behind it?
The question applies to all WinForms controls, but I use this as an example.

An image is worth a thousand words:

alt text

And a few more words:
What is behind CheckBoxpainted PictureBoxes and a Button.
The parameter is CheckBox BackColorset to Transparent. But for some reason, he decides that this means that he should share the BackColorcontaining one Form(is this his idea of ​​the illusion of transparency?).

Is this impossible in WinForms? I could swear I did it before.

UPDATE:
I just tried this:
In this form, set CheckBox BackColorto Transparent, then change the BackColorcontaining one Formto some other color, and it CheckBoxwill match that BackColor. What.......?

+3
source share
3 answers

Bob Powell wrote an excellent article on transparent controls. Check this:

http://www.bobpowell.net/transcontrols.htm

+1
source

This is a side effect of the controls that are windows windows. The window is responsible for drawing, the OnPaintBackground and OnPaint methods will take care of this.

. . Windows . , . Form.Opacity Form.TransparencyKey.

. , . , . BackColor Color.Transparent , . ButtonBase . , Windows.

" " - . . , - Z-, . , , KB, .

, WPF . , , . . , .

+6

Can you set the back of the checkbox manually to the desired color? (The value in the image window is behind it)

"Transparent" may mean something other than what you want MS.

In addition, try changing the zorder for graphic cells (bring it to the end) and see if this checkbox changes its primary color.

+1
source

Source: https://habr.com/ru/post/1778179/


All Articles