开发者

VB.net tray icon creation

开发者 https://www.devze.com 2023-02-06 22:03 出处:网络
I am dynamically creating a NotifyIcon using the code below: Dim traysystem As New NotifyIcon Question being, how can I开发者_Go百科 create a click event for that?

I am dynamically creating a NotifyIcon using the code below:

Dim traysystem As New NotifyIcon 

Question being, how can I开发者_Go百科 create a click event for that?

I've tried:

Private Sub traysystem_click(ByVal sender As System.Object, ByVal e As  _
System.EventArgs) Handles traysystem.Click
    messagebox.show("test!")
End Sub

But yeah, doesn't work.


Handles requires WithEvents in the DIM statement:

 Dim WithEvents traysystem As New NotifyIcon 

The scope of this declaration isn't obvious from the snippet. If it is a local variable then you have to use AddHandler and remove the Handles keyword:

    Dim traysystem As New NotifyIcon
    AddHandler traysystem.Click, AddressOf traysystem_click
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号