A shortcut is likely to be the easiest option. I'm not sure why you will need to prevent image resizing (which is also easy to do).
If you are worried about resizing your photo box and your shortcut is no longer centered or incorrect, you can simply put the code in a resize event that dynamically updates the size and location of the label and its font based on the current size of the image window.
However, if you are configured not to use shortcuts, you can always subscribe to your icon for the Paint event, and then use e.Graphics to simply draw text whenever the image is repainted.
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
using (Font myFont = new Font("Microsoft Sans Serif", 10))
{
e.Graphics.DrawString("This time is...Hammertime", myFont, Brushes.Black, new Point(0,0));
}
}
However, you will also have to redraw this for each iteration of your timer.
As I said, a shortcut would be a better option than this. Calling e.Graphics will not give you any real advantages over Label, but it will create more things you can worry about.
source
share