In my last blog I described how to create a window form application. In window applications the menus are essential, like we see in Microsoft office products or other application. So let’s see how menu system is implemented in window form application.
Create a window form application.
Now click on the “Toolbox”. Under “menu & Toolbars” double click drag and drop menu bar on window form.
Once we added the menu then we have to rename the menu bar, Create menu, etc. To rename the menu bar go to the property and under design change the name (in my case menuStrip MyWindow).
Let’s add menu to menu bar. When you select the menu bar it will show “Type here”, it where menu is added. Select the “type here” and type the name of menu.
We have added menu such as File and Exit. When the user clicks on file the sub menu (Exit) will came up. When click on Exit it should exit the program. To do this double click on Exit and it will show us the code tab. There we have to added “Application.Exit()”.
Now run the application and click on exit to verify it is working or not.