公告
财富商城
积分规则
提问
发文
2019-07-11 05:03发布
时光不老,我们不散
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
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();
最多设置5个标签!
Let's say the name of your MenuStrip is
fileMenu
, open it with:To show a SubMenuItem, open the ParentMenuItem and then the SubMenuStrip. Referring to your screenshot, I will name the SubMenuItem as "newMenuStrip".
When you try this, you will see no selection in the MenuStrips. So, this is your final code: