Search code examples
c#system-tray

How to grey out an option in system tray C#


The problem is quite simple: is there a way I can grey out an option in the system tray? I have seen greyed/bold out options in other programs I use, so additionally how do I bold any options.

Here is my current code:

    ContextMenu tray = new ContextMenu();
    tray.MenuItems.Add("Open", TrayClose);

    NotifyIcon trayIcon = new NotifyIcon();
    trayIcon.Text = "myBeautifulProgram";
    trayIcon.Icon = Properties.Resources.program;

    trayIcon.ContextMenu = tray;
    trayIcon.Visible = false;

So it now looks like this (ignore the border): enter image description here

Is there any way I can make this like greyed out or bold?


Solution

  • Your call

    tray.MenuItems.Add("Open", TrayClose);
    

    returns a MenuItem. It has useful members such as Enabled or DefaultItem.