Often when we click the File menu in the menu bar it expands downwards as seen in this
How can I achieve this programmatically via C# code? I need to expand the file menu as if the file menu is clicked.
Often when we click the File menu in the menu bar it expands downwards as seen in this
How can I achieve this programmatically via C# code? I need to expand the file menu as if the file menu is clicked.
Let's say the name of your MenuStrip is fileMenu
, open it with:
fileMenu.ShowDropDown();
To show a SubMenuItem, open the ParentMenuItem and then the SubMenuStrip. Referring to your screenshot, I will name the SubMenuItem as "newMenuStrip".
fileMenu.ShowDropDown();
newMenuStrip.ShowDropDown();
When you try this, you will see no selection in the MenuStrips. So, this is your final code:
fileMenu.ShowDropDown();
newMenuStrip.ShowDropDown();
newMenuStrip.DropDownItems[0].Selected();