Linked Questions

Popular Questions

Get clicked MenuStrip Item in C#

Asked by At

I want to get the name of the clicked MenuStrip Item to start other Forms depending of the name.

I tried this so far but it don't work:

private void menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
    ToolStripMenuItem mi = sender as ToolStripMenuItem;
    ToolStripItem menuItem = sender as ToolStripItem;
    if(menuItem!= null)
    {

        ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
        if(owner!= null)
        {
            Control sourceControl = owner.SourceControl;
        }
    }

}

mi and menuItem are both null. Can anyone explain me how to get the name of that item?

Related Questions