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 6938225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:27:56+00:00 2026-05-27T12:27:56+00:00

Is this possible? I plan to have 10 menu items where these are going

  • 0

Is this possible?

I plan to have 10 menu items where these are going to have sub-menu items (1 level deep only). I want to be able to filter them when the user types into my TextBox control. I know I can filter items upon opening the menu for the first time, but I want to be able to continually filter it as the user types and hide categories on the fly when the category menu item has no subitems applicable for the current filter (by name filtering).

Any ideas?

  • 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-27T12:27:56+00:00Added an answer on May 27, 2026 at 12:27 pm

    I added a context menu strip (menuStrip1). To this I added the following:

    File
       Exit
    
    Edit
       Copy
       Paste
           Further Down
    
    Help
       Arghhhh!
    

    I then added a text box (FilterMenuText), and, on the OnTextChanged event, do the following:

        private void FilterMenuText_TextChanged(object sender, EventArgs e)
        {
    
            foreach (ToolStripMenuItem menuItem in menuStrip1.Items)
            {
                if (menuItem.DropDownItems.Count > 0)
                {
                    bool matchFound = false;
    
                    foreach (ToolStripMenuItem childMenuItem in menuItem.DropDownItems)
                    {
                        if (childMenuItem.Text.ToUpper().Contains(FilterMenuText.Text.ToUpper()))
                        {
                            matchFound = true;
                            break;
                        }
                    }
    
                    menuItem.Visible = matchFound;
    
                }
            }
    
        }
    

    This will hide and show the top level MenuItems as appropriate based on the content of the child menu items. If your menu has more than one level of drop down, put the foreach into a recursive function, like:

    private void FilterMenuText_TextChanged(object sender, EventArgs e)
    {
    
        foreach (ToolStripMenuItem menuItem in menuStrip1.Items)
        {
            menuItem.Visible = MenuItemHasChildWithName(menuItem, FilterMenuText.Text);
        }
    
    }
    
    
    private bool MenuItemHasChildWithName(ToolStripMenuItem menuItem, string name)
    {
    
        if (!menuItem.HasDropDownItems)
        {
            return false;
        }
    
        bool matchFound = false;
    
        foreach (ToolStripMenuItem childMenuItem in menuItem.DropDownItems)
        {
    
            if (childMenuItem.Text.ToUpper().Contains(name.ToUpper()))
            {
                matchFound = true;
                break;
            }
    
            if (childMenuItem.HasDropDownItems)
            {
                matchFound = MenuItemHasChildWithName(childMenuItem, name);
    
                if(matchFound) { break; }
    
            }
    
        }
    
        return matchFound;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible? Like make an array with all the variables that have a
Is this possible? A group of us have been trying to prepare for a
I don't know if this is even possible but we'll see... I have a
I have a maintenance plan that looks like this... Client 1 Import Data (Success)
I want to be as efficient as possible and plan properly. Since read and
I'm going to try to make this as brief as possible while covering all
Is this possible, or is there some code that can be added so I
Is this possible to capture Windows form close event when clicked on application stop.
Is this possible ? This is with a model CUploadedFile::getInstance($model,'newsimage'); $model->image->saveAs(image\path) but I don't
Is this possible? I inserted a simple test snippet like this <script type=text/javascript>//<![CDATA[ document.write('foo');

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.