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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:08:58+00:00 2026-06-08T12:08:58+00:00

I’m using System.Windows.Forms.ContextMenu. I want to make it so when you click some of

  • 0

I’m using System.Windows.Forms.ContextMenu. I want to make it so when you click some of the buttons, it doesn’t close the menu. Right now I have it working where whenever you click one, it will reopen the menu at the same position. The only problem is it looks bad because you can see the menu flicker. Is there any better way to do this?

WPF’s ContextMenu has the StaysOpen property, but the Win Forms one doesn’t. (Is there any way I can use WPF’s ContextMenu?) I don’t want to use ContextMenuStrip, which can do this, because the ContextMenu looks a lot nicer.

Edit:

I’m not going to mark this as a solution because it’s not good to do this. If you need to do what my question asks, one way would be to make a UserControl from WPF, and then put the object with the context menu in it, then add the context menu to that. Now because it’s in WPF, on the buttons you don’t want to close the menu on click, set the property StaysOpenOnClick to true on the MenuItem. Then just put this UserControl into your WinForms app.

  • 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-08T12:08:58+00:00Added an answer on June 8, 2026 at 12:08 pm

    There’s no good way to do this using a ContextMenu control. That one is just a wrapper around the native Win32 menus, which is why it looks so much better. Its drawn using the OS APIs, just like the menus in all other applications.

    Compare that to the ContextMenuStrip control, which is completely custom drawn by the framework in C# code. It looked super cool (I guess) back when it was first released, when Windows and Office XP were the newest products on the shelves. When Windows Vista rolled out, it became horribly obsolete. The only advantage it does have is that you have a lot more fine-grained control over the menus. For example, you can host custom controls in the menus, and you can prevent the menu from closing when you click on one of the items. The native Win32 menus don’t have support for that.

    Of course, it’s more than just an oversight or accidental omission. The desire to keep a context menu open after the user has already selected something is a good clue that your design is wrong. Keep in mind that the purpose of a context menu is to give the user fast access to contextually-relevant options. All they have to do is right-click (or press a special button on their keyboard), and they can see a menu of choices directly related to what they’re working on or trying to accomplish. Just like a regular menu, they’re supposed to be able to select an option and have the menu go away.

    In Windows, all menus are “auto-close”. If the menu should be persistent, it shouldn’t be a menu at all. Consider using a toolbar, a side bar, or some type of custom control instead. Those aren’t designed to go away when one of their options are selected, and therefore they’re ideal for showing related options that should always be visible.

    If a context menu in an application didn’t go away after I selected an option, I’d consider that to be a bug. At the very least, I’d assume that my selection didn’t “take” and try clicking it again.

    I haven’t the slightest clue why the WPF team decided to provide a StaysOpen option for their context menus, or why they rewrote their own context menu class in the first place. Didn’t they learn something from the WinForms team having already done the same thing?

    The only way to do what you’re asking with the ContextMenu control (and therefore the native menus) is a hack similar to that which you describe—store the previous position of the menu, and after a command has been selected, reshow the pop-up menu in its previous location. Whatever cure you come up with for the flicker (e.g., freezing the screen and suppressing repaints until the context menu is reshown) is almost guaranteed to be worse than the disease.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.