473,395 Members | 1,689 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,395 software developers and data experts.

Creating MenuItems programaticialy

I am in a bit of a bind. I can't believe I cannot figure this out but I have
been at it all day and it is just not coming to me.

I am building menus on a form based upon an XML file. I have created a class
to do this and that part is all working just fine. My problem is the event
handler where I want all the click events to go. Not really building the
event hander, just determining the individual menuItem that triggered the
handler is my problem.

My event handler looks like this:

Private Sub MenuClick(ByVal sender As Object, ByVal e As System.EventArgs)

Dim menuItem As MenuItem

menuItem = sender

Debug.WriteLine("--" & menuItem.Text)

End Sub
What I want to be able to do it look at something on the sender object (like
a name or tag property) and determine what exact MenuItem triggered the
event (I have all my menuitems going to the same handler).

I thought that when I was creating my individual MenuItems I would be able
to assign each of them an individual name like:

mnuFile
mnuFileNew
mnuFileNewMessage
.... etc ...

and then be able to get then in code as something like sender.name or
something, but I can't seem to be able to do that.

All that I seem to be able to do it get the Text of the sender and this just
gets me the menu text, not really helpful in the long run.

Besides rolling my own MenuItem class just to add some type of property like
Tag or Name, is there any way that I can do this? I know that I can use
sender.GetType().Name but all this does is return the string 'MenuItem' and
that is no good to me.


Nov 20 '05 #1
0 734

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

Similar topics

1
by: Venkatesh | last post by:
Hi Everybody, This is the first timw I am entering into this Group. I am developing a VB Project with an MDI form. I want to display IE Favorites into my application. For this I need to...
1
by: Yigit Ozgul | last post by:
Hi, I have a database where i keep 4 tables. the modules table: mdlID mdlName mdlstatus the submodules table:
0
by: Deutsche Dogge | last post by:
Hi. I'M having a weird problem with addign menuitems to a menu dynamically on the popup event of the menuitem containing the container of the menuitems i wanna add (tools -> external -> {list of...
0
by: Kreisquadratur | last post by:
Below is s snippet of my code, which should add menuitems as a submenu of an item in a contextmenu. But only the first time the contextmenu opens the entrys are set correctly. I just don't know why...
1
by: Steve Tan | last post by:
1. How can I loop through all the items and subitems for Menu of a Windows Form (c#) ? Recursive function? 2. How can I uniquely identify a submenu item ? MenuItems doesn't have a Name...
0
by: Brian | last post by:
Create a simple MDI form and a child form, and try the following simple code to add a new menu item on the Edit menu popup: private void editMenu_Popup(object sender, System.EventArgs e) {...
5
by: Davie | last post by:
I'm developing an application on the smartphone. To reduce the size of the application i'm using panels where appropriate instead of forms. As a result of the design, I need to have different...
4
by: Ray Cassick \(Home\) | last post by:
I am in a bit of a bind. I can't believe I cannot figure this out but I have been at it all day and it is just not coming to me. I am building menus on a form based upon an XML file. I have...
2
by: csgraham74 | last post by:
Hi there, just wondering if someone could help me. Ive written some code in vb.net to create the following xml. <menu> <menuItem> <text>Political Update</text> </menuItem> <subMenu />
3
by: active | last post by:
I have a mainmenu menuitem that contains a Recently Used Files menuitem If at design time I include a menuitem in the Recently Used Files menuitem collection it will display OK If I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.