J'ai un utilisateur personnalisé C#-contrôle où je voudrais dessiner un cercle derrière une zone de texte ancrée au fond centré du contrôle. Je dessine le cercle comme:GraphicsPath, contrôle sur le dessus
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);
}
J'ai ajouté la zone de texte au contrôle dans le concepteur d'interface graphique.
Quand je lance ce je me retrouve avec quelque chose comme ceci:
alt text http://i47.tinypic.com/2pyrxbk.jpg
Comment puis-je garder l'ellipse derrière la zone de texte?
Merci, Mark
@Philip, je ne suis pas sûr de comprendre et cela peut être mon problème. La région de l'ellipse est le contrôle (this.region). Ai-je besoin de nourrir la région d'autre chose? – Mark
Donner l'ellipse sa propre région a fonctionné! – Mark