System tray icon with c# Console Application won't show menu

前端 未结 4 1449
名媛妹妹
名媛妹妹 2021-01-02 15:32

I\'ve got a small C# (.NET 4.0) Console Application that I\'d like the user to be able to interact by showing a menu when they right-click the System Tray icon. I can add an

4条回答
  •  猫巷女王i
    2021-01-02 16:11

    Did you add the event-handler for tray Icon mouse click?

    trayIcon .MouseDown += new MouseEventHandler(trayIcon_MouseDown);
    

    create context menu and do as following inside the trayIcon_MouseDown function

    private void trayIcon_MouseDown (object sender,MouseEventArgs e)
    {
      //add you menu items to context menu
      contextMenu.Items.Add(item);
      contextMenu.IsOpen = true;  
    }
    

    Try this. Think this will help you.

提交回复
热议问题