我有一个定制的C#用户控件,在这里我想在后面画一个圆圈,,一个被锚定在控件中央底部的文本框。我在画圆圈,就像:
protected override void OnResize(EventArgs e)
{
this.gp= new GraphicsPath();
this.gp.AddEllipse(0,0,width,height); //this is the width and height of the control
this.Region=new Region(this.gp);
this.Refresh();
base.OnResize (e);
}
protected override void OnPaint(PaintEventArgs pe)
{
Color centerColor = Color.FromArgb(255,255,255,255);
Color surroundColor = Color.FromArgb(255,255,255,255);
PathGradientBrush br=new PathGradientBrush(this.gp);
br.CenterColor=centerColor;
br.SurroundColors=new Color[]{surroundColor};
pe.Graphics.FillPath(br,this.gp);
}我已经将textbox添加到GUI设计器中的控件中。
当我运行这个程序时,我会得到这样的结果:

如何将椭圆保留在文本框后面?
谢谢,马克
发布于 2010-02-09 17:26:46
如果您希望在后台这样做,请在"OnPaintBackground“覆盖中而不是在OnPaint中这样做。然后,当您想要绘制它时,使椭圆所在的区域失效。
https://stackoverflow.com/questions/2230944
复制相似问题