473,414 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Context Menu: specifying the sub to handle the menu selection

When I am typing the argument(s) of the Add method of MenuItems, one of the
options (#2 of 5) provides for 'OnClick as System.EventHandler' (as the
second arguement), which I hope is to provide a reference to the 'Handler'
sub:

mnuTopics.MenuItems.Add("DoSomething", DoSomething_Handler)

What is the corresponding sub syntax? The following is not the correct
syntax.

Private Sub mnuTopics_DoSomething_Handler(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles mnuTopics.DoSomething_Handler

Thanks

Nov 20 '05 #1
4 1241
Try this

MnuTopics.MenuItems.Add("DoSomething", AddressOf DoSomthing_Handler)

"tmaster" <le*******@travelmasterusa.com> wrote in message
news:BX****************@fe1.columbus.rr.com...
When I am typing the argument(s) of the Add method of MenuItems, one of the options (#2 of 5) provides for 'OnClick as System.EventHandler' (as the
second arguement), which I hope is to provide a reference to the 'Handler'
sub:

mnuTopics.MenuItems.Add("DoSomething", DoSomething_Handler)

What is the corresponding sub syntax? The following is not the correct
syntax.

Private Sub mnuTopics_DoSomething_Handler(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles mnuTopics.DoSomething_Handler

Thanks

Nov 20 '05 #2
Hello

In assuming that you intend to dynamically add menu items based upon some
need during runtime your handler sub only needs to look like the code below.
You would be using the same handler for all of the added menu items. Within
that handler you could branch off to different procedures based upon the
value of the sender object. If the menu additions are part of a 'Plug-In'
scheme you could use reflection to direct execution flow to the proper
procedures.

Private Sub MenuClickhandler(ByVal sender As Object, _
ByVal e AsSystem.EventArgs)

End Sub


--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================
Pocket PC Return On Investment Calculator
Free Download http://64.78.34.175/mcsnet/kwickKalk1.aspx
"tmaster" <le*******@travelmasterusa.com> wrote in message
news:BX****************@fe1.columbus.rr.com...
When I am typing the argument(s) of the Add method of MenuItems, one of the options (#2 of 5) provides for 'OnClick as System.EventHandler' (as the
second arguement), which I hope is to provide a reference to the 'Handler'
sub:

mnuTopics.MenuItems.Add("DoSomething", DoSomething_Handler)

What is the corresponding sub syntax? The following is not the correct
syntax.

Private Sub mnuTopics_DoSomething_Handler(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles mnuTopics.DoSomething_Handler

Thanks

Nov 20 '05 #3
* "tmaster" <le*******@travelmasterusa.com> scripsit:
When I am typing the argument(s) of the Add method of MenuItems, one of the
options (#2 of 5) provides for 'OnClick as System.EventHandler' (as the
second arguement), which I hope is to provide a reference to the 'Handler'
sub:

mnuTopics.MenuItems.Add("DoSomething", DoSomething_Handler)


\\\
Me.Menu.MenuItems.Add("&Help", AddressOf MenuItem2_Click)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Try

mnuTopics.MenuItems.Add("DoSomething", New EventHandler(AddressOf
mnuTopics_DoSomething_Handler))

The Sub seems fine
remove the "handles" clause

Manasvin

"tmaster" <le*******@travelmasterusa.com> wrote in message news:<BX****************@fe1.columbus.rr.com>...
When I am typing the argument(s) of the Add method of MenuItems, one of the
options (#2 of 5) provides for 'OnClick as System.EventHandler' (as the
second arguement), which I hope is to provide a reference to the 'Handler'
sub:

mnuTopics.MenuItems.Add("DoSomething", DoSomething_Handler)

What is the corresponding sub syntax? The following is not the correct
syntax.

Private Sub mnuTopics_DoSomething_Handler(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles mnuTopics.DoSomething_Handler

Thanks

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: news.microsoft.com | last post by:
Hi everyone, Please I'm creating a Context Menu and doing a manual Show from C#, on a different thread I need to know the window size of the Context Menu already opened, I have the object...
4
by: Phill | last post by:
Here's what I'm doing to make the right context mnue show up based on what node was cliked: private void tvwMenu_MouseUp(object sender, MouseEventArgs e) { //Select Node When Right Clicked &...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
2
by: Paul E Collins | last post by:
A context menu is created in the scope of the RightClick event, but it continues to be displayed after that event handler terminates - i.e. after it has gone out of scope. The code works correctly,...
2
by: Gary Wessle | last post by:
Hi I need help organizing this program in the right way. I included the code below which compiles and runs and gives the desired effect to a certain point, but I don't know what the next step...
1
by: Preeti | last post by:
Hi all I am a fresher and have been given a requirement in VB.net I have to make an application in VB.net which will run as a system tray icon and will add one or two items in the default...
1
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.