Michael Weston Michael Weston - 8 months ago 64
C# Question

Adding images to buttons from Imagelist on a toolstrip?

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.


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