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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:11:39+00:00 2026-05-13T17:11:39+00:00

I want to have it such that left clicking on the NotifyIcon also causes

  • 0

I want to have it such that left clicking on the NotifyIcon also causes the context menu (set with the ContextMenuStrip property) to open as well. How would I achieve this? Do I have to handle Click and figure out the positioning myself?
Edit: showing the menu with trayIcon.ContextMenuStrip.Show() results is a few undesirable behaviors:

The menu is not shown at the same location as if right click the NotifyIcon (it appears that you can’t set the x and y coords to where the taskbar is, at least on Windows 7 which is what I’m running). It will appear above the task bar (not that big of a deal, but consistency would be nice).

While the menu is shown, there is an extra icon added to the task bar.

Clicking somewhere other than the menu does not close it (whereas if you right click to bring up the context menu clicking else where automatically closes the context menu).

Is it at all possible to just invoke the menu however the built in right click handler is doing it?

  • 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-13T17:11:40+00:00Added an answer on May 13, 2026 at 5:11 pm

    You would normally handle the MouseClick event to detect the click and call the ContextMenuStrip.Show() method:

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e) {
            contextMenuStrip1.Show(Control.MousePosition);
        }
    

    But that doesn’t actually work properly, the CMS won’t close when you click outside of it. Underlying issue is a Windows quirk (aka “bug”) that is described in this KB article.

    Invoking this workaround in your own code is pretty painful, the pinvoke is unpleasant. The NotifyIcon class has this workaround in its ShowContextMenu() method, they just made it difficult to get to since it is a private method. Reflection can bypass that restriction. I discovered this hack 5 years ago and nobody reported a problem with it yet. Set the NFI’s ContextMenuStrip property and implement the MouseUp event like this:

    using System.Reflection;
    ...
        private void notifyIcon1_MouseUp(object sender, MouseEventArgs e) {
          if (e.Button == MouseButtons.Left) {
            MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
            mi.Invoke(notifyIcon1, null);
          }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such view that handles user registration. After creating new user i want
I want to have a contact us on my site such that a user
I want to absolute position a div such that the top left corner of
I have an absolutely positioned [element] such that in the CSS, I've explicitly set
I am new to php. I want to have a form such as this:
I want to have a large 2 dimensional array such like int myArray[10000][2]; I
I want to have a generic function for a few types such as long,
I want to make a user-registration form where I will have fields such first
Suppose I have an IEnumerable such as a List(TValue) and I want to keep
I have several number inputs of varying lengths which I want to style such

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.