Resolved CustomControl Transparent BackGround

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
129
Programming Experience
10+
I am writing a CustomControl. It is inherited from Control. I would like the user to be able to set the background of the control to ANY color including Transparent. When I try and set it "as a user", I get the error: "Control does not support transparent background colors.". Any ideas on how to make this work?
 
Solution
Simple enough. I guess I should have done more research. I simply added the following line to the Control Initialization:

Set Control to support Transparent Color:
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
Simple enough. I guess I should have done more research. I simply added the following line to the Control Initialization:

Set Control to support Transparent Color:
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
 
Solution
I am writing a CustomControl. It is inherited from Control. I would like the user to be able to set the background of the control to ANY color including Transparent. When I try and set it "as a user", I get the error: "Control does not support transparent background colors.". Any ideas on how to make this work?

How can I make a custom control support transparent background colors, even though the Control class does not support it? I would be very happy if you could let me know, thanks. I know this is an old discussion but the answer to my question is very important I am appealing to the admin. Please approve my post, Thanks
 
@inaya10 : Did you try the solution that the OP found himself? If that didn't work, please start a brand new thread. You can reference this thread by saying that you tried the solution in the other thread (and put a URL to this old thread). Be sure to tell us what you tried, and share a minimal amount of code to reproduce the problem.
 
Back
Top Bottom