I would like to make an entire Control and its children have a see-through effect so that it looks disabled.
My Control was initially a UserControl but trying to change the alpha on the BackColor yielded an exception so I made it a Form instead.
I have tried the methods outlined in my code but the form just doesn't want to become transparent.
Microsoft's documentation stated: "The Opacity property enables you to specify a level of transparency for the form and its controls."
Source: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.opacity
This is what had led me to believe making the form and its child controls transparent is a possibility.
MyTransparentWindow has some text fields and buttons on it in the designer.
public partial class frmMain : Form {
public frmMain()
{
InitializeComponent();
instance = this;
}
private void frmMain_Load(object sender, EventArgs e)
{
this.Controls.Add(new MyTransparentWindow());
}
}
public partial class MyTransparentWindow : Form {
public MyTransparentWindow()
{
InitializeComponent();
this.TopLevel = false;
this.FormBorderStyle = FormBorderStyle.None;
this.ControlBox = false;
this.ShowInTaskbar = false;
this.StartPosition = FormStartPosition.Manual;
this.AutoScaleMode = AutoScaleMode.None;
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
this.Opacity = 0.5;
}
}