In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces VB.NET how to create a menu project, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
First, let's review some of the basics of the menu. In order to use menus in your application, you need to create a main menu project at design time using the MainMenu component, which will allow you to: create and add new menus and new menu bars; use property windows to change menu item properties; and create event handlers for menu events.
Create a VB.NET menu project at design time
You can find the MainMenu component in the forms toolbox. To add a MainMenu component to your form, you can drag the control onto the form or right-click on the control.
With the MainMenu component, you can quickly and easily add menus to VB.NET 's Windows forms, and the menus displayed in your forms are the same as those displayed at run time. As you type, additional menu boxes appear to the right of the * menu items, and submenus can be created in the same way. If you want to create a submenu, simply enter an entry to the right of the menu item you want to extend.
Manipulate VB.NET menu items at run time
You can dynamically manipulate menu items at run time, which is necessary if you need to respond to an action by a software user to display a particular set of menus. It is also useful to use this feature to prevent menus from responding to errors. You can choose to add, hide, or disable menus at run time, and make the same choice for the check buttons next to them.
Example of VB.NET menu item operation code
In listing A, I created three new menu items, mnuMenuItem1, mnuMenuItem2, and mnuMenuItem3. I added mnuMenuItem1 and mnuMenuItem2 to the MainMenu1 menu, and set mnuMenuItem3 as a submenu of mnuMenuItem2. Notice that I set the selected property (Checked) of mnuMenuItem3 to True and place a check box next to this project. I also defined two events: mnuMenuItem1_Click and mnuMenuItem3_Click. When the user clicks on the menu, a message dialog box will be displayed, and the code in list A should look similar to figure B.
List A:
Private Sub Form1_Load ()
Sub Form1_Load (ByVal sender
As System.Object, ByVal e
As System.EventArgs)
Handles MyBase.Load SetMenus ()
End Sub
Private Sub SetMenus ()
Sub SetMenus ()
Dim mnuMenuItem1 As MenuItem
MnuMenuItem2 As MenuItem
MnuMenuItem3 As MenuItem
MnuMenuItem1 = New MenuItem
("Item 1", New EventHandler
(AddressOf mnuMenuItem1_Click))
MainMenu1.MenuItems.Add (mnuMenuItem1)
MnuMenuItem2 = New MenuItem ("Item2")
MainMenu1.MenuItems.Add (mnuMenuItem2)
MnuMenuItem3 = New MenuItem
("Item 3", New EventHandler
(AddressOf mnuMenuItem3_Click))
MnuMenuItem3.Checked = True
MnuMenuItem2.MenuItems.Add
(mnuMenuItem3)
End Sub
Private Sub mnuMenuItem1_Click ()
Sub mnuMenuItem1_Click (ByVal
Sender As Object, ByVal e As
System.EventArgs)
MessageBox.Show ("Menu Item"
1 Clicked ")
End Sub
Private Sub mnuMenuItem3_Click ()
Sub mnuMenuItem3_Click (ByVal
Sender As Object, ByVal e As
System.EventArgs)
MessageBox.Show ("Menu"
Item 3 Clicked ")
End Sub
Thank you for reading this article carefully. I hope the article "how to create menu items in VB.NET" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.