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

  • Home
  • SEARCH
  • 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 6057957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:32:44+00:00 2026-05-23T08:32:44+00:00

How do i dynamically remove a ToolStripMenu Item. I have two events that fire

  • 0

How do i dynamically remove a ToolStripMenu Item. I have two events that fire one to add a name and one to remove a name. Adding names works. Removing does not. When i debug my remove i can see that {Poco} in in the DropDownItems. However when i call remove it does not get removed

// Adding items works as expected
ToolStripMenuItem mi = new ToolStripMenuItem("Poco");
mi.CheckOnClick = true;
myToolStripMenuItem.DropDownItems.Add(mi);

i have tried a lot of things.. what i thought would work was this

// This does not work .. how do i fix this?
myToolStripMenuItem.DropDownItems.RemoveByKey("Poco");

what is the correct way of removing name?

  • 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-05-23T08:32:44+00:00Added an answer on May 23, 2026 at 8:32 am

    The ToolStripItemCollection.Item property allows you to seek by the item name – as long as it’s set for the object itself – so if I assume one cannot add duplicate strings as the menu items, initializing the object with the text to display along with its name should enable you to remove it later:

    ToolStripMenuItem mi = new ToolStripMenuItem("Poco"){ Name = "Poco" };
    

    and then further on your processing remove it with the same code you have (I assume it should work):

    //Should now work based on MS's comment for the Name property:
    //The Name property can be used as a key into the ToolStripItemCollection.
    myToolStripMenuItem.DropDownItems.RemoveByKey("Poco");
    

    I unfortunately can’t test it at the moment, no .NET on this Mac. 🙂 However, I’m pretty sure you can Remove() it by directly referencing the object in the collection:

    myToolStripMenuItem.DropDownItems.Remove(myToolStripMenuItem.DropDownItems["Poco"]);
    

    Again, too bad I can’t test right away for a definite answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that I want to dynamically remove based on a link.
I have an Ajax form that lets me dynamically remove rows from a table
I am using ASP.NET ajax to dynamically add/remove controls from a page without using
The problem Dynamically add and remove fields to entities on the fly using Hibernate.
I am dynamically adding ImageViews to a RelativeLayout depending on user input. I have
I have a table that I am trying to dynamically delete rows from. Each
I currently have javascript/jquery to 'add and remove' steps from a set of instructions
I hope this is any easy one. I have a view that I want
I'm dynamically loading user controls adding them to the Controls collection of the web
How would you dynamically subscribe to a C# event so that given a Object

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.