I am creating a contextmenu that should contain a listing of all folders, subfolders, and files in a chosen folder. I want the menu to open the files and folders when they are clicked, but the click event doesn't register if the menuitem has subitems.
void Foo(string Title)
{
MenuItem = new MenuItem(Title);
MenuItem.Click += new EventHandler(MenuItem_Click);
ContextMenu.MenuItems.Add(MenuItem);
}
void MenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("This box will only show when menuitems without subitems are clicked");
}
How can I make the click event fire even if the menuitem has subitems?