By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,150 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

Adding Menuitems to Contextmenu doesn't work

P: n/a
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 or how to
solve this problem...

private void contextMenu1_Popup(object sender, System.EventArgs e)
{
contextMenu1.MenuItems[0].MenuItems.Clear();
Process[] myProcesses = Process.GetProcessesByName("IEXPLORE");
if (myProcesses.Length > 0)
{
contextMenu1.MenuItems[0].Enabled = true;
foreach (Process process in myProcesses)
contextMenu1.MenuItems[0].MenuItems.Add("(" +
process.Id.ToString() + ") : " + process.MainWindowTitle.ToString(),
new EventHandler(processmenu_clicked));
}
else
contextMenu1.MenuItems[0].Enabled = false;
}
Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.