0
我有一個自定義的C#用戶控件,我想繪製一個圓圈後面一個文本框錨定到控件的中心底部。我正在畫圓:GraphicsPath,頂部控制
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);
}
我在GUI設計器中添加了文本框到控件中。
當我運行此我結束了這樣的事情:
alt text http://i47.tinypic.com/2pyrxbk.jpg
我如何才能讓文本框後面的橢圓形?
謝謝, 馬克
@Philip,我不確定我是否理解,這可能是我的問題。橢圓的區域是控制(this.region)。我需要把它餵給別的地方嗎? – Mark 2010-02-09 17:51:38
給橢圓它自己的區域工作! – Mark 2010-02-09 18:25:40