M
M
<see code snippet below>
I'm trying to determine how I can tell when a user clicks
A->1->a OR
A->3->b OR
D->4->c ...
While in the handler I cannot determine what sequence of menu items and sub
menu items brought me there.
If anyone has any ideas or can show me in code what I should do I would
highly appreciate it.
Thanks
public class MyPopUpSubSubMenu : ContextMenu
{
public MyPopUpSubSubMenu()
{
MenuItems.Add(new MenuItem("a"));
MenuItems.Add(new MenuItem("b"));
MenuItems.Add(new MenuItem("c"));
MenuItems.Add(new MenuItem("d"));
}
};
public class MyPopUpSubMenu : ContextMenu
{
public MyPopUpSubMenu()
{
MenuItems.Add(new MenuItem("1"));
MenuItems.Add(new MenuItem("2"));
MenuItems.Add(new MenuItem("3"));
MenuItems.Add(new MenuItem("4"));
m_SubSubMenu = new MyPopUpSubSubMenu();
MenuItems[0].MergeMenu(m_SubSubMenu);
MenuItems[1].MergeMenu(m_SubSubMenu);
MenuItems[2].MergeMenu(m_SubSubMenu);
MenuItems[3].MergeMenu(m_SubSubMenu);
}
public MyPopUpSubSubMenu m_SubSubMenu;
};
public class MyPopUpMenu : ContextMenu
{
public MyPopUpMenu()
{
MenuItems.Add(new MenuItem("A"));
MenuItems.Add(new MenuItem("B"));
MenuItems.Add(new MenuItem("C"));
MenuItems.Add(new MenuItem("D"));
m_SubMenu = new MyPopUpSubMenu();
MenuItems[0].MergeMenu(m_SubMenu);
MenuItems[1].MergeMenu(m_SubMenu);
MenuItems[2].MergeMenu(m_SubMenu);
MenuItems[3].MergeMenu(m_SubMenu);
}
public MyPopUpSubMenu m_SubMenu;
};
public class Form1 : System.Windows.Forms.Form
{
public MyPopUpMenu myPopUpMenu;
private void Form1_Load(object sender, System.EventArgs e)
{
myPopUpMenu = new MyPopUpMenu();
//myPopUpMenu.MenuItems[0].MenuItems[0].Popup += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[0].Click += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[1].Click += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[2].Click += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[3].Click += new
EventHandler(this.WhoseCallingMe);
this.ContextMenu = myPopUpMenu;
}
public void WhoseCallingMe(object sender, System.EventArgs e)
{
MessageBox.Show("How can I tell who called me?");
}
}
I'm trying to determine how I can tell when a user clicks
A->1->a OR
A->3->b OR
D->4->c ...
While in the handler I cannot determine what sequence of menu items and sub
menu items brought me there.
If anyone has any ideas or can show me in code what I should do I would
highly appreciate it.
Thanks
public class MyPopUpSubSubMenu : ContextMenu
{
public MyPopUpSubSubMenu()
{
MenuItems.Add(new MenuItem("a"));
MenuItems.Add(new MenuItem("b"));
MenuItems.Add(new MenuItem("c"));
MenuItems.Add(new MenuItem("d"));
}
};
public class MyPopUpSubMenu : ContextMenu
{
public MyPopUpSubMenu()
{
MenuItems.Add(new MenuItem("1"));
MenuItems.Add(new MenuItem("2"));
MenuItems.Add(new MenuItem("3"));
MenuItems.Add(new MenuItem("4"));
m_SubSubMenu = new MyPopUpSubSubMenu();
MenuItems[0].MergeMenu(m_SubSubMenu);
MenuItems[1].MergeMenu(m_SubSubMenu);
MenuItems[2].MergeMenu(m_SubSubMenu);
MenuItems[3].MergeMenu(m_SubSubMenu);
}
public MyPopUpSubSubMenu m_SubSubMenu;
};
public class MyPopUpMenu : ContextMenu
{
public MyPopUpMenu()
{
MenuItems.Add(new MenuItem("A"));
MenuItems.Add(new MenuItem("B"));
MenuItems.Add(new MenuItem("C"));
MenuItems.Add(new MenuItem("D"));
m_SubMenu = new MyPopUpSubMenu();
MenuItems[0].MergeMenu(m_SubMenu);
MenuItems[1].MergeMenu(m_SubMenu);
MenuItems[2].MergeMenu(m_SubMenu);
MenuItems[3].MergeMenu(m_SubMenu);
}
public MyPopUpSubMenu m_SubMenu;
};
public class Form1 : System.Windows.Forms.Form
{
public MyPopUpMenu myPopUpMenu;
private void Form1_Load(object sender, System.EventArgs e)
{
myPopUpMenu = new MyPopUpMenu();
//myPopUpMenu.MenuItems[0].MenuItems[0].Popup += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[0].Click += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[1].Click += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[2].Click += new
EventHandler(this.WhoseCallingMe);
myPopUpMenu.MenuItems[0].MenuItems[0].MenuItems[3].Click += new
EventHandler(this.WhoseCallingMe);
this.ContextMenu = myPopUpMenu;
}
public void WhoseCallingMe(object sender, System.EventArgs e)
{
MessageBox.Show("How can I tell who called me?");
}
}