473,835 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event Handling With Dynamic ToolStripMenu

The following method adds items to a toolstripmenu named colums

public void AddColumnMenu()
{
foreach (ColumnHeader column in messagesListVie w.Columns)
{

ToolStripMenuIt em item =
(ToolStripMenuI tem)columnsTool StripMenuItem.D ropDownItems.Ad d(column.Text);
item.Checked = true;
item.CheckOnCli ck = true;

}
}

How do you add event handling for each menu item added? What I am
going to end up doing is allow the user to expand or remove a column
by clicking that column name in the columns menu.

May 17 '07 #1
2 7101
What's wrong wiht good old ToolStripMenuIt em.Click+=new EventHandler(<y our
handler>); ?

Something like:

ToolStripMenuIt em item =
(ToolStripMenuI tem)columnsTool StripMenuItem.D ropDownItems.Ad d(column.Text);
item.Checked = true;
item.CheckOnCli ck = true;
item.Click+=new EventHandler(Ha ndleDynamicMenu Click);

}

void HandleDynamicMe nuClick(object sender, EventArgs e)
{
ToolStripItem item=(ToolStrip Item)sender;
MessageBox.Show ("Selected menu " + item.Text);
}

<Am************ @gmail.comha scritto nel messaggio
news:11******** ************@w5 g2000hsg.google groups.com...
The following method adds items to a toolstripmenu named colums

public void AddColumnMenu()
{
foreach (ColumnHeader column in messagesListVie w.Columns)
{

ToolStripMenuIt em item =
(ToolStripMenuI tem)columnsTool StripMenuItem.D ropDownItems.Ad d(column.Text);
item.Checked = true;
item.CheckOnCli ck = true;

}
}

How do you add event handling for each menu item added? What I am
going to end up doing is allow the user to expand or remove a column
by clicking that column name in the columns menu.
May 17 '07 #2
Yep.. thats what I ended up doing. Im kind of a C# newb. Sorry for
the dumb question lol

On May 17, 10:32 am, "Laura T." <laura_...@yaho o.comwrote:
What's wrong wiht good old ToolStripMenuIt em.Click+=new EventHandler(<y our
handler>); ?

Something like:

ToolStripMenuIt em item =
(ToolStripMenuI tem)columnsTool StripMenuItem.D ropDownItems.Ad d(column.Text);
item.Checked = true;
item.CheckOnCli ck = true;
item.Click+=new EventHandler(Ha ndleDynamicMenu Click);

}

void HandleDynamicMe nuClick(object sender, EventArgs e)
{
ToolStripItem item=(ToolStrip Item)sender;
MessageBox.Show ("Selected menu " + item.Text);
}

<AmericanGot... @gmail.comha scritto nel messaggionews:1 1************** ******@w5g2000h sg.googlegroups .com...
The following method adds items to a toolstripmenu named colums
public void AddColumnMenu()
{
foreach (ColumnHeader column in messagesListVie w.Columns)
{
ToolStripMenuIt em item =
(ToolStripMenuI tem)columnsTool StripMenuItem.D ropDownItems.Ad d(column.Text);
item.Checked = true;
item.CheckOnCli ck = true;
}
}
How do you add event handling for each menu item added? What I am
going to end up doing is allow the user to expand or remove a column
by clicking that column name in the columns menu.- Hide quoted text -

- Show quoted text -

Jun 15 '07 #3

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

Similar topics

8
2835
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the boxes and saving to the database at the end with the 'Submit' command button. Is it possible to save the changes as the checkboxes are clicked? I suppose I'd need to write some dynamic ASP event handling at the same time as creating the checkboxes......
10
3611
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
1
20709
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function init() {
15
26522
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
0
1983
by: VBTricks.de.vu Webmaster | last post by:
Hello, I want to display the Edit-menu of my application (ToolStripMenu) as context menu. Using the old ContextMenu class I just cloned all items in the MenuItem.ChildItems collection. But the ToolStripMenu class unfortunately does not have a Clone method. So how to display the menu as contextmenu? Thanks in advance,
2
3843
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At runtime, the placeholder control adds a dropdownlist where I would like it to redirect the user to a different page dependent on the selection they make from the dropdownlist. I've tried writing the delegate and the event handler both in the
4
2098
by: reggiestyles | last post by:
Hi, I've got a question about prototype and event handling. I've got several div's (dynamic number) on a page that I want to set as active or inactive (basically, I'm using scriptaculous' Effects to set Opacity to 1 for the active div and 0.5 for the inactive ones). Using prototype's event handling, I can see two ways to get this done:
1
5366
by: Jeremy Martin | last post by:
Hi, I am currently learning c# so be gentle :) I am converting a Delphi.NET website to c# website and I am confused as to how events are handled. 2 Situations. 1. A component on a webusercontrol fires a postback event. On postback
1
108793
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back button anyways, if the user ventures away from your page then they wouldn't have this button at their disposal. The main reason people ask how to control or disable the back button is because they have a need to control sensitive (and/or) dynamic web...
0
9808
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10812
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10561
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9346
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7766
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6966
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
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
2
3995
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.