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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:19:52+00:00 2026-05-27T05:19:52+00:00

I’m trying to implement a ‘preview’ scenario when the user hover a menu item.

  • 0

I’m trying to implement a ‘preview’ scenario when the user hover a menu item.

For example, lets say a program has a context-menu with ‘Set Color’ sub-menu.
The sub-menu pop a list of color to choose from.
Now, when the mouse cursor is over a specific color, I want it to change a label of “Selected color”.
And when the mouse cursor leave the selected color menu-item, I want to label to restore its original text.

The following code demonstrate changing the label when menu-item selected – mouse is over.

    private void Init()
    {
        var mnuContextMenu = new ContextMenu();
        this.ContextMenu = mnuContextMenu;

        var smthingElseMenu = new MenuItem("Do something else");
        var setColorMenu = new MenuItem("Set Color");

        var colorBlue = new MenuItem("Blue");
        var colorRed = new MenuItem("Red");
        var colorGreen = new MenuItem("Green");

        mnuContextMenu.MenuItems.Add(smthingElseMenu);
        mnuContextMenu.MenuItems.Add(setColorMenu);
        setColorMenu.MenuItems.Add(colorBlue);
        setColorMenu.MenuItems.Add(colorRed);
        setColorMenu.MenuItems.Add(colorGreen);

        colorBlue.Select += ColorSelect;
        colorRed.Select += ColorSelect;
        colorGreen.Select += ColorSelect;
    }

    void ColorSelect(object sender, EventArgs e)
    {
        lblSelectedColor.Text = ((MenuItem) sender).Text;
    }

But I couldn’t find a way to make the label text restore when the mouse cursor leave the menu-item.
Any ideas how can I implement some kind of ‘Unselect’/’MouseLeave’ event for MenuItem?

  • 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-27T05:19:53+00:00Added an answer on May 27, 2026 at 5:19 am

    There’s no “un-select” event for MenuItems, unfortunately.

    I would just catch the Collapse event of your context menu, and reset your label there. This would have the added benefit that if your user hovers over the “Red” option, then hovers off the context menu, the label should stay red until the context menu closes.

    mnuContextMenu.Collapse += (s, e) => lblSelectedColor.Text = "None";
    

    If you really need it to reset the label when your mouse leave the context menu, then you could catch the MouseEnter event of the Panel (or whatever) you have that surrounds the ContextMenu.

    MyPanel.MouseEnter += (s, e) => lblSelectedColor.Text = "None";
    

    EDIT Do consider using the ContextMenuStrip class instead. The ToolSTripMenuItem class has a MouseLeave event. And a Checked property, probably what you really want.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string

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.