mardi 31 mars 2015

ToolStripMenuItem: Add arrow without submenu

How can I add a menu item that has an arrow to the right as if there would be a submenu but does not show a submenu?


Background: For a managed C# application I want to add a submenu which is created in an unmanaged DLL (using TrackPopupMenu()).


In my experiments, I can only show the arrow when there are items attached using "DropDownItems.Add".


I tried to use



ToolStripMenuItem menu = new ToolStripMenuItem();
m_menu.Text = "Item that should have arrow w/o submenu";
m_menu.Click += this.OnMenuDoSomething;
m_menu.DropDownItems.Add("");


This still adds a submenu. I then tried these combinations:



m_menu.DropDownItems[0].Enabled = false;
m_menu.DropDownItems[0].Available = false;
m_menu.DropDownItems[0].Visible = false;


but either the submenu including the arrow disappears or nothing at all.


Aucun commentaire:

Enregistrer un commentaire