Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8929991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:47:17+00:00 2026-06-15T08:47:17+00:00

There is a ContextMenuStrip in a grid control. I have named it as GridContextMenu.

  • 0

There is a ContextMenuStrip in a grid control.

I have named it as GridContextMenu.

The GridContextMenu is populated with 4 – 5 items using the following code :

 gridcontextMenu.Items.Add(new ToolStripMenuItem
                        {
                            Name = Plants,
                            Text = Plants,
                            Tag = Plants,
                            Width = 100,
                            Image = <image source is put here>
                        });

gridcontextMenu.Items.Add(new ToolStripMenuItem
                        {
                            Name = Animals,
                            Text = Animals,
                            Tag = Animals,
                            Width = 100,
                            Image = <image source is put here>
                        });

For the animal menu in tool strip, i added submenu in the following way

(gridcontextMenu.Items[1] as ToolStripMenuItem).DropDownItems.Add("Tiger", image_source, new EventHandler(SubmenuItem_Click));
(gridcontextMenu.Items[1] as ToolStripMenuItem).DropDownItems.Add("Lion", image_source, new EventHandler(SubmenuItem_Click));
(gridcontextMenu.Items[1] as ToolStripMenuItem).DropDownItems.Add("Elephant", image_source, new EventHandler(SubmenuItem_Click));

In the SubmenuItem_Click event handler i need to know which animal submenu was clicked.

How to achieve this ?

currently i have the code for event handler in the following way :

private void SubmenuItem_Click(object sender, EventArgs e)
{
}

How to check condition in this event that which animal submenu was selected ?
Kindly share the answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:47:18+00:00Added an answer on June 15, 2026 at 8:47 am

    You can do something like this:

    private void SubmenuItem_Click(object sender, EventArgs e)
    {
        var clickedMenuItem = sender as MenuItem; 
        var menuText = clickedMenuItem.Text;
    
        switch(menuText) {
            case "Tiger":
               break;
    
            case "Lion":
              break;
             . ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have contextMenuStrip and there be always 3 items. First item will be start/stop
WinForms .NET 3.5 We have a contextMenuStrip for data grid. This contextMenuStrip can hold
I have added a few custom MenuItem objects to a ContextMenuStrip control. However, adding
I have a winforms ContextMenuStrip that has ToolTipText set for all of it's ToolStripMenuItem's.
I'm using the following code to display a context menu on my form when
Is there an event that fires in vb.net just before a contextMenuStrip appears when
I have a ContextMenuStrip (ctMenuMassEdit) that I want to display when left-clicking a button
I'm using NotifyIcon (System tray icon) in my WinForms application. I also have a
I am using the ToolStripDropDown to host the user control as the pop-up window.
I am using an old ActiveX control in my C# Win App. it has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.