473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"How to create click event handler dynamically for each submenuitem"

Hi,
I m developing a Windows application in which i want to create a
context menu, having variable number of submenus depending on the the
list in the file. I m able to create these submenus at runtime by
reading the file. But the problem is that there is no fixed count of
submenus and becaz of that i m not able to figure out "How to create
click event handler dynamically for each submenuitem"? Please help.
Thanks,
Nikki

Nov 17 '05 #1
2 2773
Assign the same click event to each menu option, then in the handler use the
name to determine which was clicked.

ie.
public void AllMenuOptions_ Clicked(object sender, ...)
{
switch( ((Control)sende r).Name).ToStri ng())
{
case "mnuFile":
<whatever>
break;

case "mnuEdit":
<whatever>
break;
}
}

You can do more funky stuff with reflection but thats a different story.
"Nikki" <ap*********@gm ail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
Hi,
I m developing a Windows application in which i want to create a
context menu, having variable number of submenus depending on the the
list in the file. I m able to create these submenus at runtime by
reading the file. But the problem is that there is no fixed count of
submenus and becaz of that i m not able to figure out "How to create
click event handler dynamically for each submenuitem"? Please help.
Thanks,
Nikki

Nov 17 '05 #2

Thanks Mr. Adam Barker.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3

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

Similar topics

0
1075
by: tommy | last post by:
hello everybody, i haved read a few articles about, how to create controls in asp.net dynamically! i have tested it -- all works fine.... but....now it comes--> HOW create controls dynamically using a html-table.... i want to display dynamically on each row one button, and dont use datagrid.
4
1600
by: Robin Tucker | last post by:
Hi there, I need to add a click handler to a derived menu item class. I am using the same handler to handle all of the items in the given menu, but need to derive a new menu item class in order to store a little extra information for each item. Previously, I was writing: MyMenu.MenuItems.Add ( "the text label", New...
4
1269
by: Lars Netzel | last post by:
Is there any way to add some code that will happen in every single Event that i raised in a form? I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might affect it Is there are was to keep that Filed Total (a value) updated at all time without...
3
1224
by: Sakharam Phapale | last post by:
Hi All, I am working on a project, where maximum operations carried out on Files and multi-dimensional arrays. Since array data is huge application takes too much memory. My problem is, after few operations, toolbar on MDI from doesn't catch "Click" event. But it catch all other events like mouse leave etc.
41
4270
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. ...
3
3972
by: JohnR | last post by:
I have a form with a number of text boxes, comboboxes etc. What I would like to do is create an event handler for the "mouseenter" event for each of the controls whereby I display information about the control they just entered (sort of like an extended tooltip). Now, I can certainly create a separate mouseenter event for each control (too...
21
8126
by: Ben | last post by:
Hello I have frames set up in an asp.net application and need one frame to refresh another. Seeing as events need to be registered at the time the page is sent from the server, I was wondering if I could place a hidden button in a frame that would have the attribute to refresh the other. I would need code to "invoke" the onclick event (ie...
2
1383
by: loga123 | last post by:
Hi All, I am new to .net. I am creating a text box in a "button1" "click event" dynamically based on user input. Name of the text box and ID of the text box contro are set dynamically in the server side code. How can make this text box accessable in another "sub" or "button2" click event? Any help is greatly appreciated.' thanks
3
4453
Curtis Rutland
by: Curtis Rutland | last post by:
OK, I have a question. I have a problem. I'm trying to catch all KeyDown events on a button, but the problem is when I press the "Enter" key, the button's "Click" event is triggered, not the "KeyDown" event. Or if it is, it isn't being caught by the handler. Is there a way to disable the button being clicked by pushing Enter?
0
7701
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7677
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.