Hey all I am trying to figure out why my text is not showing past my picturebox:
The code I am using is this:
flowLayoutStations.Controls.Add(P);
I know its because its being added to the picturebox (P) but i am not sure how to go about setting the picturebox and the behind so that the text can be dominant on top f it?
The code I am using is this:
C#:
Image NewImage = Image.FromFile(imgSaveResized + newImgExt);
NewImage = NewImage.GetThumbnailImage((int)(NewImage.Width * 0.5), (int)(NewImage.Height * 0.5), null, IntPtr.Zero);
PictureBox P = new PictureBox();
P.SizeMode = PictureBoxSizeMode.AutoSize;
P.Image = NewImage;
P.Margin = new Padding(5, 5, 55, 35);
P.Paint += new PaintEventHandler((sender, e) =>
{
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
string text = "Text";
Font myFont = new Font("Arial", 18, FontStyle.Italic, GraphicsUnit.Pixel);
SizeF textSize = e.Graphics.MeasureString(text, Font);
PointF locationToDraw = new PointF();
locationToDraw.X = (P.Width / 2) - (textSize.Width / 2);
locationToDraw.Y = (P.Height / 2) - (textSize.Height / 2)+85;
e.Graphics.DrawString(text, myFont, Brushes.Red, locationToDraw);
});
flowLayoutStations.Controls.Add(P);
I know its because its being added to the picturebox (P) but i am not sure how to go about setting the picturebox and the behind so that the text can be dominant on top f it?