How can I write text to a picturebox?
-
For the project I am working on, if I cannot find an image, I am going to write the image name to the picturebox instead. However, there doesn't seem to be a straightforward property (like "Text") that I can use. Is there an easy way to do this?
-
For the project I am working on, if I cannot find an image, I am going to write the image name to the picturebox instead. However, there doesn't seem to be a straightforward property (like "Text") that I can use. Is there an easy way to do this?
Andrew Stampor wrote:
Is there an easy way to do this?
Define easy ;P One way would be to replace, at run time, the picture box with another control, like label, that has a text property. To keep the picture box you would need to create an image and write the text on to it, then assign it to the picture box. There numerous examples of how to do this.
only two letters away from being an asset
-
Andrew Stampor wrote:
Is there an easy way to do this?
Define easy ;P One way would be to replace, at run time, the picture box with another control, like label, that has a text property. To keep the picture box you would need to create an image and write the text on to it, then assign it to the picture box. There numerous examples of how to do this.
only two letters away from being an asset
You can place a label over a picturebox and change its visibility according to existence of picture
-
You can place a label over a picturebox and change its visibility according to existence of picture
picturebox.visible = false; label.visible = true; This essentially replaces the picturebox with the label control.
only two letters away from being an asset
-
picturebox.visible = false; label.visible = true; This essentially replaces the picturebox with the label control.
only two letters away from being an asset
I only have access to the picturebox itself. Using a label would be a good way, but I cannot rely on it. I think I will try to override the OnPaint, but it seems like more trouble than it should be.
-
I only have access to the picturebox itself. Using a label would be a good way, but I cannot rely on it. I think I will try to override the OnPaint, but it seems like more trouble than it should be.
Andrew Stampor wrote:
I only have access to the picturebox itself.
You can override the OnPaint event but you can't place a label control on the form?:confused:
only two letters away from being an asset
-
Andrew Stampor wrote:
I only have access to the picturebox itself.
You can override the OnPaint event but you can't place a label control on the form?:confused:
only two letters away from being an asset
The picturebox is inherited from and extended. I do not know which form(s) it will necessarily be on. I was able to take care of it with OnPaint. Thanks for your help, guys.
-
For the project I am working on, if I cannot find an image, I am going to write the image name to the picturebox instead. However, there doesn't seem to be a straightforward property (like "Text") that I can use. Is there an easy way to do this?
Yes, create a bitmap, draw the string onto it, and put it in the picturebox.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I only have access to the picturebox itself. Using a label would be a good way, but I cannot rely on it. I think I will try to override the OnPaint, but it seems like more trouble than it should be.
you can use a label as a pictureBox so catch two birds in one hand ;)
-
For the project I am working on, if I cannot find an image, I am going to write the image name to the picturebox instead. However, there doesn't seem to be a straightforward property (like "Text") that I can use. Is there an easy way to do this?
Bitmap bm = new Bitmap(@"C:\YourPicture.bmp");
Graphics gr = Graphics.FromImage(bm);
gr.DrawString(""test", new Font("Verdana", (float)10, FontStyle.Bold, GraphicsUnit.Pixel), new SolidBrush(Color.Red),(float)20, (float)20);
gr.Dispose();
pictureBox1.Image = bm;
Smile: A curve that can set a lot of things straight! (\ /) (O.o) (><)