Reputation: 81
I am looking to change the image of the button on the tool strip after it is selected. The image property is system.drawing.bitmap and was saved to Properties\Resources.resx file. Thanks in advancen
An explanation of the logic would be nice too!
Upvotes: 2
Views: 6673
Reputation: 1296
First, you should set the CheckOnClick property to true then, it is possible to save the last status of button
this.toolStripMuteButton.CheckOnClick = true;
if (toolStripMuteButton.Checked)
{
this._lastMicVol = tag.Volume;
this.toolStripMuteButton.Image = lobal::Properties.Resources.microphone2;
tag.Volume = 0;
}
else
{
this.toolStripMuteButton.Image = global::Properties.Resources.microphone1;
tag.Volume = this._lastMicVol;
}
Upvotes: 2
Reputation: 1
Create an
ImageList imageList1;
and add the images you require.
To change the toolStripButton image
you must do:
toolStripButton1.Image = imageList1.Images[imageIndex];
Upvotes: 0
Reputation: 21
The code I found that works is:
toolStripButton.Image = Image.FromFile("directory of your file");
During a button click event, just call this code, and the image will change
Upvotes: 2