开发者

VB.net tray icon creation

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜