110,561
社区成员
发帖
与我相关
我的任务
分享
//要设置带alpha值的颜色
BackColor = Color.FromArgb(128,0,0,0);
public class ButtonEx : Control
{
public ButtonEx()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.UserPaint, true);
UpdateStyles();
BackColor = Color.FromArgb(128,255,0,0);
}
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
Graphics g = pevent.Graphics;
g.DrawImage("半透明的png格式图片",0,0);
}
}