winforms - Change size of ToolStripMenuItem -


i'm custom drawing menu item in menustrip. problem i'm having menu item insists on sizing based on text, not want (there no text). can set autosize false , explicitly specify size, containing menu (toolstripdropdown) still sizes based on text, causes small contain entire menu item.

is there straightforward way set size of menu item?

it can achieved adding empty image toolstripitem. change size of image give desired size toolstripitem. have done in project below:

using system; using system.collections.generic; using system.drawing; using system.windows.forms;  public partial class form1 : form {         public form1()     {         bitmap emptyimage = new bitmap(48, 48);         toolstripmenuitem  m_item = new toolstripmenuitem(system.convert.tostring("all       programs",emptyimage);         m_item.imagealign = contentalignment.middleleft;         m_item.imagescaling = toolstripitemimagescaling.none;                                 m_item.name = btnid.tostring();         menustrip menu = new menustrip();         menu.items.add(m_item);     } } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -