c# forms mainmenu
I have a winform that I have a main menu going horizontally across as such:
MenuItem opt1 = new MenuItem();
opt1.Text = "Save Image";
opt1.Click += new EventHandler(opt1_Click);
MenuItem opt2 = new Menu开发者_运维技巧Item();
opt2.Text = "Upload Data";
opt2.Click += new EventHandler(opt2_Click);
mainMenu.MenuItems.Add(opt1);
mainMenu.MenuItems.Add(opt2);
form.Menu = mainMenu;
What I want is when the user clicks on 'Upload Data' a drop down menu to show, with a small number of other options. Could somebody please point me in the right direction as to what I should be looking at?
Thanks.
Just add menu items to the opt2
opt2.MenuItems.Add(....)
Add some items to opt2.MenuItems
to create a submenu.
I would use the Windows Forms designer. If you can't, use it to click together a dummy form with the required menu and then look in the code that was generated, copy that one.
精彩评论