This snippet shows how to develop a custom panel which is semi transparent by overriding CreateParams and the OnPaint method of the Panel control.
xPanel
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
class xPanel: Panel
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
}
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, 0,0,0)), this.ClientRectangle);
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
}
}
No comments:
Post a Comment