Change the image on a button
-
:confused: Hello, I have an a button on a form, the button has an image set at design time. if certain conditions are met i would like to change the image on this button to a different image. both images in question are loaded as an application resource and appear as an image in the resources (My.resources.). I tried going the route of: if "condition met" then me.btnX.image = my.resources.image2 end if this does not work! any thoughts would be appreciated. Thanks!
-
:confused: Hello, I have an a button on a form, the button has an image set at design time. if certain conditions are met i would like to change the image on this button to a different image. both images in question are loaded as an application resource and appear as an image in the resources (My.resources.). I tried going the route of: if "condition met" then me.btnX.image = my.resources.image2 end if this does not work! any thoughts would be appreciated. Thanks!
private void button1_Click(object sender, EventArgs e) { pictureBox1.Image = WindowsApplication5.Properties.Resources.image2; }
I have tried with BMP image. It works fine.Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
private void button1_Click(object sender, EventArgs e) { pictureBox1.Image = WindowsApplication5.Properties.Resources.image2; }
I have tried with BMP image. It works fine.Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
- The image is loaded into a button (not a picture box) - I am also coding in VB.Net VS2005, so to access the image in resources i refrence it as follows: My.Resources.ImageName The reference you listed: WindowsApplication5.Properties.Resources... is not in vs2005 Can any one help? -- modified at 16:42 Tuesday 21st August, 2007
-
:confused: Hello, I have an a button on a form, the button has an image set at design time. if certain conditions are met i would like to change the image on this button to a different image. both images in question are loaded as an application resource and appear as an image in the resources (My.resources.). I tried going the route of: if "condition met" then me.btnX.image = my.resources.image2 end if this does not work! any thoughts would be appreciated. Thanks!
-
- The image is loaded into a button (not a picture box) - I am also coding in VB.Net VS2005, so to access the image in resources i refrence it as follows: My.Resources.ImageName The reference you listed: WindowsApplication5.Properties.Resources... is not in vs2005 Can any one help? -- modified at 16:42 Tuesday 21st August, 2007
rnamro wrote:
The reference you listed: WindowsApplication5.Properties.Resources... is not in vs2005
I'm using VS 2005 and C# as language."WindowsApplication5" is the project name.
button1.BackgroundImage = WindowsApplication5.Properties.Resources.logo ;
Okay. I will give you the VB.NET 2005 code. Please try the following steps. - Create the new VB.NET window application in Visual Studio 2005 In Solution Explorer ~ 1. Go to My Project under project root. 2. Double click to open the properties. 3. Go to "Resources" 4. Click "Add Resource" and "Add existing file" 5. ("File Open" dialog will be opened) Select the picture. 6. then, Save 7. Go to button Click event. (Make button a lit bit larger to see the image.) 8. Write the code belowPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Button1.BackgroundImage = My.Resources.Image1 End Sub
9. Run the application 10. Click the button (Observe: the image will be shown on the button) Hope it helps.Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)