473,399 Members | 2,278 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,399 software developers and data experts.

Generic menu event for a menu with dynamic items

Hi all,

I have a menu that is populated from the results of an SQL query. For
example lets say the menu contains a list of clients IDs. I would like to
click on a particular item and open up a form passing in the particular
client ID that I have clicked on.

It is possible to have a generic event that is activated for any item that
is selected in the menu?
regards,

Mac

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
2 1360
"Mac via DotNetMonster.com" <fo***@nospam.DotNetMonster.com> schrieb:
I have a menu that is populated from the results of an SQL query. For
example lets say the menu contains a list of clients IDs. I would like to
click on a particular item and open up a form passing in the particular
client ID that I have clicked on.

It is possible to have a generic event that is activated for any item that
is selected in the menu?


Extend each meu item with a 'Tag' property:

<URL:http://www.dotnetrix.co.uk/menus.html>
-> "Create an Extender Component to add a Tag property to MenuItems."

Then use 'AddHandler' to add an event handler which is shared between all
menu items. Inside the event handler check the menu item's tag ('sender'
will contain a reference to the menu item).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Hi add a mainmenu to a form, add one item to the mainmenu then
copy paste the following code in the form load event and copy paste the
Private Sub MenuItem_Click somewhere outside the form load event, and test
the app.
Dim x As MenuItem
For i As Integer = 0 To 9
x = New MenuItem
x.Text = CStr(i)
AddHandler x.Click, AddressOf MenuItem_Click
MainMenu1.MenuItems(0).MenuItems.Add(x)
Next
Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
MsgBox(DirectCast(sender, MenuItem).Text)
End Sub
hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Mac via DotNetMonster.com" <fo***@nospam.DotNetMonster.com> schreef in
bericht news:23******************************@DotNetMonste r.com...
Hi all,

I have a menu that is populated from the results of an SQL query. For
example lets say the menu contains a list of clients IDs. I would like to
click on a particular item and open up a form passing in the particular
client ID that I have clicked on.

It is possible to have a generic event that is activated for any item that
is selected in the menu?
regards,

Mac

--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #3

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

Similar topics

4
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
1
by: tribal boy | last post by:
Guys, I am using a dynamic menu which uses xml,xsl a css file and javascript. This works fine when there are no server controls around or underneath it. The problem is whenever the menu...
6
by: Sandy | last post by:
Hello - I have a book that illustrates pulling menu items from a Sql Server table into an ascx via a stored procedure. Is this something that is done in the real world? I do like the effect...
0
by: Jay | last post by:
I am having a lot of trouble getting the Site Navigation Controls to work. Now I am on to the Menu Control I cannot get the MenuItemClick event to work. For one Menu that is in a master page...
0
by: arun | last post by:
I am having a lot of trouble getting the Site Navigation Controls to work. Now I am on to the Menu Control I cannot get the MenuItemClick event to work. For one Menu that is in a master page...
1
by: xpnctoc | last post by:
Here's the 30,000-ft. view: I wrapped an asp:Menu control in an ascx control. When I try to dynamically populate the menu in the ascx control, the items appear, but clicking on them fails to trigger...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
0
by: =?Utf-8?B?SmltSGVhdmV5?= | last post by:
I am have a ASP:Menu with static and dynamic menu items. Each of the static items has dynamic menu items. If the user clicks on a static menu item, which has no click event, then menu item...
3
by: =?Utf-8?B?ZWFndWlsYXI=?= | last post by:
Hi, I am trying to dynamically generate a menu, based on entries on a text or xml file. The text file contains the "tree" after which the menu will need to be created. Something like the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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: 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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.