首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GraphicsPath,顶层控制

GraphicsPath,顶层控制
EN

Stack Overflow用户
提问于 2010-02-09 17:08:31
回答 1查看 421关注 0票数 0

我有一个定制的C#用户控件,在这里我想在后面画一个圆圈,,一个被锚定在控件中央底部的文本框。我在画圆圈,就像:

代码语言:javascript
复制
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设计器中的控件中。

当我运行这个程序时,我会得到这样的结果:

如何将椭圆保留在文本框后面?

谢谢,马克

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-09 17:26:46

如果您希望在后台这样做,请在"OnPaintBackground“覆盖中而不是在OnPaint中这样做。然后,当您想要绘制它时,使椭圆所在的区域失效。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2230944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档