Link to home
Start Free TrialLog in
Avatar of tsmolskow
tsmolskow

asked on

.NET 2.0 with toolstrip

I'm using .NET 2.0 with a tooltsrtip in a form.  I have added a button to the tool strip, and I used the image property to assign a image to the button.  Now I want to create a pressed in pushed out effect with two different images.  My question is, how do I dynamically change the image associated with the button on the toolstrip?
Avatar of nayernaguib
nayernaguib
Flag of Egypt image

Use the following statement:

            myToolStrip.Items(index).Image = System.Drawing.Image.FromFile("filePath") 'or any other image source

_______________

  Nayer Naguib
Avatar of tsmolskow
tsmolskow

ASKER

Right, I guess I didn't write my question well, I wanted the flow logic code to be able to switch back and forth between images, right now I'm using a resource file and this code to change images:

toolStripButton4.Image = Prototype.Properties.Resources.PushPin_Selected.png;

But i'm not sure of the logic I need to switch the pin images from selected to unselected and back based on the click event
ASKER CERTIFIED SOLUTION
Avatar of nayernaguib
nayernaguib
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's not working, here's my code:

     private void toolStripButton4_Click(object sender, EventArgs e)
     {
 
            if (toolStripButton4.Checked)
            {
                toolStripButton4.Image = Prototype.Properties.Resources.color_tab_enemy_selected;
            }
            else
            {
                toolStripButton4.Image = Prototype.Properties.Resources.color_tab_enemy_unselected;
            }
     }


   Am I missing a setting on the control?
OK, I found it, I had to set the CheckOnClick event to true - thanks again Nayer