Display image in menu items in Windows Forms ContextMenuStrip (ContextMenuStripEx)

Displaying an image besides each menu item helps users to easily identify the operation through iconic representation and also to improve the visual appearance of the context menu item. Images can be added directly via the Image property of each menu item. The size of the images can be adjusted by using the ImageScalingSize property.

NOTE:

  1. Image can be set only for menu items not for combobox and textbox.
  2. Image will be displayed only if ShowImageMargin property of ContextMenuStripEx is set to true.

The following code snippet illustrates how to add a image in menu item.

this.contextMenuStripEx.ShowImageMargin = true;
this.contextMenuStripEx.ImageScalingSize = new System.Drawing.Size(24, 24);
this.toolStripMenuItem1.Image = System.Drawing.Image.FromFile(@"..\..\..\new.png");
this.toolStripMenuItem2.Image = System.Drawing.Image.FromFile(@"..\..\..\copy.png");
Me.contextMenuStripEx.ShowImageMargin = True
Me.contextMenuStripEx.ImageScalingSize = New System.Drawing.Size(24, 24)
Me.toolStripMenuItem1.Image = System.Drawing.Image.FromFile("..\..\..\new.png")
Me.toolStripMenuItem2.Image = System.Drawing.Image.FromFile("..\..\..\copy.png")

Display image in menu items