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.