adding an icon image for a button

1 Answer 5713 Views
Visual Studio Extensions
David T.
Top achievements
Rank 1
David T. asked on 17 Jun 2013, 07:16 PM
I am aware that you can add an icon image through the property -> images -> and import an image from there.  I was trying to find a way to hard code this because for one button, i want to alternate between 2 different images.  I was wondering if you could provide a link or example code of how i can do that, or how to hard code an icon image into a command bar button.

1 Answer, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 18 Jun 2013, 02:37 PM
Hello David,

Thank you for contacting us.

To change a button's image with code you need to change its Image property. See the example belowIf you want to cut the size of the picture to 100x100px:
this.commandBarButton1.Image = Image.FromFile("button-pic.jpg").GetThumbnailImage(100, 100, null, IntPtr.Zero);

If you want to keep the picture's original size:
this.commandBarButton1.Image = Image.FromFile("button-pic.jpg");

For any further questions do not hesitate to contact us.

Regards,
George
Telerik
RadChart for WinForms is obsolete. Now what?

this.commandBarButton1.Image = Image.FromFile("button-pic.jpg")
Fran
Top achievements
Rank 1
commented on 17 Mar 2017, 08:23 PM

THANK YOU VERY MUCH MAN!!!!
Tags
Visual Studio Extensions
Asked by
David T.
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or