Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding images to buttons from Imagelist on a toolstrip?

Tags:

c#

Does anyone know why Microsoft got rid of the ImageList property on toolbars? Where is the best place to assign an imagelist manually? Would I be able to get the images to display during design time if the only images I can add or change is from a local resource or project resource file? How do I get the specific imagelist index to show on the buttons in toolstrip during design time.

like image 498
Michael Weston Avatar asked Nov 06 '25 22:11

Michael Weston


1 Answers

It is still there for ToolBars but ToolBars are being replaced by ToolStrips.

One of the ToolStrip subclasses is MenueStrip. Both ToolStrip and MenueStrip, have an ImageList property.

However, for reasons unknown, the ImageList property doesn't show up in the property tab:

enter image description here

However you can set it in code and Intellisense will help you..:

enter image description here

Unfortunately this will not help when working in the designer. One can subclass ToolStrip to expose the ImageList but the ToolStripItems don't expose their ImageIndex properties either, so this doesn't help.

All ToolStripItems have an Image property, though, and after adding your Images to the resources you can pull them in from there.

Looks like this is how we are supposed to do it now..? Wouldn't it be nice to have a word about this in the documentation. Or maybe someday soon (most likely sooner) in SO Documentation?!

I think this is a case of nudging us away from ImageList; one of the advantages is that now you can give each item a different image size, some square others wider..

like image 160
TaW Avatar answered Nov 09 '25 14:11

TaW



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!