0

I need to be able to set an icon on a ToolStripStatusLabel item in a C# Windows Forms application. The item will being displaying an image and text. I assumed that I could use an Icon with such an item but I am mistaken. What is the best way of creating an Image object from an existing Icon object?

the intended code will look something like:

Image image = new Image(); // Get this image somehow from a pre-existing Icon object
serverInfoToolStripStatusLabel.Text = "Connected to server X";
serverInfoToolStripStatusLabel.Image = image;

(NB: serverInfoToolStripStatusLabel is declared as System.Windows.Forms.ToolStripStatusLabel) regards.

Plastikfan
  • 3,674
  • 7
  • 39
  • 54

2 Answers2

0

Icon has the ToBitmap method, which will give you a Bitmap, which is an Image

Timores
  • 14,439
  • 3
  • 46
  • 46
0

You can set the image directly in designer.

If you have to use code, why not add the image to your project Resources and then assign the image property to it?

Girl Spider
  • 330
  • 2
  • 6