By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

Context menu and notifyicon - event not firing?

P: n/a
Hi, I've got a simple program that contains a windows form with 3 command
buttons on. The project also includes a notifyicon and a context menu. The
context menu has 3 menu items (mirroring the 3 command buttons), with each
menu item firing the corresponding command buttons performclick event (eg.
on selecting menuitem1, fires the command1.performclick event).
Problem is that occassionally, selecting the menuitems does nothing. Any
ideas? Would it be better to place the commandbutton code into seperate
procedures and call these from the menu and commandbuttons?

Mark
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
* "riggs" <ri*****@hotmail.com> scripsit:
Hi, I've got a simple program that contains a windows form with 3 command
buttons on. The project also includes a notifyicon and a context menu. The
context menu has 3 menu items (mirroring the 3 command buttons), with each
menu item firing the corresponding command buttons performclick event (eg.
on selecting menuitem1, fires the command1.performclick event).
Problem is that occassionally, selecting the menuitems does nothing. Any
ideas? Would it be better to place the commandbutton code into seperate
procedures and call these from the menu and commandbuttons?


Does this sample work for you?

<http://www.mvps.org/dotnet/dotnet/samples/windowsandforms/downloads/SimpleNotifyIcon.zip>

Does the code work if you do not use 'PerformClick'?

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Dilbert's words of wisdom #18: Never argue with an idiot. They drag you down
to their level then beat you with experience.
Nov 20 '05 #2

P: n/a

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e2****************@TK2MSFTNGP12.phx.gbl...
Does the code work if you do not use 'PerformClick'?


Hi Herfried, I added a bit of code to one of my menu items, so that it would
display a messagebox before performing the 'performclick' :

Private Sub mnuupdate_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles mnuupdate.Click
MessageBox.Show("hello")
cmdupdate.PerformClick()
End Sub

The messagebox was displayed, but the cmdupdate code was not executed.

Mark
Nov 20 '05 #3

P: n/a
* "Mark Harris" <ri*****@hotmail.com> scripsit:
Does the code work if you do not use 'PerformClick'?


Hi Herfried, I added a bit of code to one of my menu items, so that it would
display a messagebox before performing the 'performclick' :

Private Sub mnuupdate_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles mnuupdate.Click
MessageBox.Show("hello")
cmdupdate.PerformClick()
End Sub

The messagebox was displayed, but the cmdupdate code was not executed.


Add the code from 'cmdUpdate_Click' to a separate procedure. Then call
this procedure from the button's 'Click' event handler and
'mnuupdate_Click' instead of using 'PerformClick'.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Dilbert's words of wisdom #18: Never argue with an idiot. They drag you down
to their level then beat you with experience.
Nov 20 '05 #4

P: n/a

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...

Add the code from 'cmdUpdate_Click' to a separate procedure. Then call
this procedure from the button's 'Click' event handler and
'mnuupdate_Click' instead of using 'PerformClick'.


That does the trick.

Thanks
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.