110,533
社区成员
发帖
与我相关
我的任务
分享
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(this._opacity, this.BackColor)),
this.ClientRectangle);
g.DrawImage(ForeImage, new Rectangle(new Point(0, 0), ForeImage.Size));
public partial class widget_button : rtgui_BaseWidget
{
public widget_button()
{
InitializeComponent();
this.FlatStyle = System.Windows.Forms.FlatStyle.Flat; //在这里报错
}
}
我在下面生成对应属性 public FlatStyle FlatStyle { get; private set; } // 这个属性需要进行别的操作吗?
我刚接触自定义控件,有些东西不是太懂,麻烦您讲解一下 this.TextAlign = ContentAlignment.MiddleCenter;
时,说TextAlign未定义.
现在我是这样的情况: 自定义个基础控件(baseWidget),里面有控件的部分基本属性,类似于control,
后面自定义控件的时候,就在这个baseWidget上面进行自定义其他的控件来使用 public class TransparentPanel : Panel
{
public TransparentPanel()
{
SetStyle(ControlStyles.SupportsTransparentBackColor
| ControlStyles.Opaque,
true);
BackColor = Color.Transparent;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | 0x20;
return cp;
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (BackColor != Color.Transparent)
{
var bounds = new Rectangle(0, 0, Width - 1, Height - 1);
const int alpha = 128;
using (var bckColor = new SolidBrush(Color.FromArgb(alpha, BackColor)))
{
e.Graphics.FillRectangle(bckColor, bounds);
}
}
base.OnPaint(e);
}
protected override void OnBackColorChanged(EventArgs e)
{
//Parent?.Invalidate(this.Bounds, true);
base.OnBackColorChanged(e);
}
protected override void OnParentBackColorChanged(EventArgs e)
{
Invalidate();
base.OnParentBackColorChanged(e);
}
}
this.TextAlign = ContentAlignment.MiddleCenter;
时,说TextAlign未定义.
现在我是这样的情况: 自定义个基础控件(baseWidget),里面有控件的部分基本属性,类似于control,
后面自定义控件的时候,就在这个baseWidget上面进行自定义其他的控件来使用[/quote]
非常有意义