how to exclude control from a WinForm.Opacity in C#
.net, c#, winforms
Solution
Since `Control` doesn't have `Opacity` property and plus that, most of the controls doesn't support transparent colors, then a working solution can be this:
Create a `Form` called `MainForm` and place all the controls you're going to be excluded.
1.1 Set both of `BackColor` and `TransparencyKey` properties of `MainForm` to the same color, e.g `Color.Red`
Create another form named `TransparentForm` and place all controls that must become transparent. Set `ShowInTaskbar` property to `False`.
In the `MainForm` `Load` event show the `TransparentForm` and send it to back.
private void MainForm_Load(object sender, EventArgs e)
{
TransparentForm form = new TransparentForm();
form.Opacity = 0.5D;
form.Show();
form.SendToBack();
}
The position of controls in both form must be such that, when combined, it shows the proper user interface.
Problem
I have a form that i set it's Opacity as 50% like this: ``` this.Opacity = 0.5D; <--this==Form ``` My problem is that everything that on the form is with an Opacity of 50% I have two buttons on the form and I want them without Opacity. I know that `this.Opacity` included all Controls and for some reason the graphics too My question is, How to Exclude the Opacity of the controls? Example Image: Thanks!