I was wondering how to change or modify the transparency of a Panel in C#, not the whole form, but the panel only.. I've seen many C# tutorials on Opacity, but its for the Form. im looking for how it could be possible with the Panel only. Thank You!
For whoever is still looking for a totally transparent panel, I found a nice solution in this blog by William Smash who in turn has taken it from Tobias Hertkorn on his T# blog. I thought its worth posting it as an answer here.
public class TransparentPanel : Panel
{
protected override CreateParams CreateParams
{
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//base.OnPaintBackground(e);
}
}
Public Class TransparentPanel
Inherits Panel
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20 ''#WS_EX_TRANSPARENT
Return cp
End Get
End Property
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
''#MyBase.OnPaintBackground(e)
End Sub
End Class