Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 17-Apr-13 4:37am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100