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 is about how VB.NET uses NotifyIcon controls. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The programming environment used in this paper is Microsoft Visual Studio 2005. First, open Visual Studio. On the File (File) menu, click New Project (New Project). In the template (Templates) pane of the New Project (New Project) dialog box, click Windows Application (Windows Application). Click OK (OK).
To minimize the form icon to be automatically hidden to the taskbar, we can use a control called the VB.NET NotifyIcon control, open the toolbox on the left, find the VB.NET NotifyIcon control and drag it directly onto the form. Set the Icon property of NotifyIcon, and of course you can set a good-looking icon for the ICON property.
Click on the Form1 form, enter the property settings, and set the WindowState of the Form to the Minimized;ShowInTaskbar property to False.
Next, we're going to enter the code.
Private Sub Form1_Resize (ByVal sender As Object
ByVal e As System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide ()
End If
End Sub
In the Resize code event of Form, the code means that the form is automatically hidden to the status bar when it is minimized. In this way, the form will be automatically hidden at run time and appear in the status bar. If you want to double-click the icon to display the form, you can set the DoubleClick code of the VB.NET NotifyIcon control.
The code is as follows:
Private Sub NotifyIcon1_DoubleClick (ByVal sender As Object
ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
Me.ShowInTaskbar = True
Me.Show ()
Me.WindowState = FormWindowState.Normal
End Sub
If we want to create a right-click menu, we can add a ContextMenustrip control to the form and associate it with the ContextMenu property of NotifyIcon. Select the menu and toolbar in the toolbox, drag the ContextMenu control directly onto the form to enter the property settings, and enter the corresponding menu keywords (the text you want to enter is the software version of the figure below, etc.). Then click the NotifyIcon1 control of the form, set the properties, and select the right-click menu ContextMenustrip1 you just edited at contextmenustrip to associate it.
Then press F5 to run the program, click the form minimize button, the icon of the form is automatically hidden to the status bar. Click on the right button and you can see the beautiful right-click menu.
Thank you for reading! This is the end of this article on "how VB.NET uses NotifyIcon controls". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.