看了不少所谓的透明标签,都是假的。相对父控件透明 并不是真正的透明。这个才是真的,如假包换。
class SuLabel : Label
{
public SuLabel()
{
}
protected override void OnPaint(PaintEventArgs e)
{
int fontstyleIndex = 0;
fontstyleIndex = (int)Font.Style;
BackColor = ForeColor;
GraphicsPath gp = new GraphicsPath();
gp.AddString(Text, Font.FontFamily, fontstyleIndex, Font.Size, ClientRectangle, StringFormat.GenericDefault);
this.Region = new Region(gp);
gp.Dispose();
}
}
绝对原创,转载注明出处。。。。。。。