Click here to Skip to main content
15,861,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i change the color of the button by adding a different image from image list

Button1.Image=ImageList1.Images[1]

'getting error value of type system.windows.form.imagelist1.imagecollection can not be converted in system.drawing.image

i need the button color(image) should change after a certain condition is met
Posted

1 solution

I wouldn't do that at all if I wanted that functionality. I would use a toolstrip instead of a button. You can float them anywhere on your form, and make them transparent. You can set up a number of buttons, and hide the button with the image you want to remove, and show the button with the one you want to show. This makes adding functionality for the different button states easier, as they each have their own event handler. I did this in my CodeProject article:

SharpZipLib or DotNetZip... Which should you use?

Why not download the project and have a look? I think you'll be happier doing it this way then using a standard button. I never use them anymore myself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900