text sur graphic de PictureBox qui disparaît
Bonsoir,
Je mets du texte sur une pictureBox directement sur son graphic.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
//this est un picturebox
graph = this.CreateGraphics();
font = new Font("Microsoft Sans Serif", (float)8.5, FontStyle.Bold);
format = new StringFormat(StringFormatFlags.NoClip);
format.Alignment = StringAlignment.Center;
brush = new SolidBrush(Color.Black);
size = new Size(this.Width, (int)font.GetHeight());
rectangleF = new RectangleF(new Point(0, 0), size);
sizeF = graph.MeasureString(Name, font);
if (sizeF.Width > this.Width)
{
this.Width = (int)Math.Ceiling(sizeF.Width);
}
graph.DrawString(Name, font, brush, rectangleF, format); |
Chaque fois que mon application est repeinte, mon texte disparaît.
Aucun événement Paint ou Validated n'est levé dans ce cas. Donc pas moyen de réafficher mon texte.
Y aurait-il moyen de fixer mon texte sur le PictureBox ?