且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

左键单击上下文菜单

更新时间:2023-12-06 09:05:04

我有点玩这个并想出了以下想法...



在您的notificationIcon上,不要设置 ContextMenuStrip 属性(即你不会得到默认行为)



然后尝试将代码显示在 MouseUp $ c $中显示您的上下文菜单c> notificationIcon上的事件。例如......

I had a bit of a play with this and came up with the following idea...

On your notificationIcon, do not set the ContextMenuStrip property (i.e. you won't get the default behaviour)

Then try putting the code to show your context menu in the MouseUp event on the notificationIcon. For example ...
private void notificationIcon_MouseUp(object sender, MouseEventArgs e)
{
      ContextMenuStrip cm = new ContextMenus().Create();
      cm.Show(Cursor.Position.X, Cursor.Position.Y);

      //the line below is how I was playing with a dummy menu
      //this.contextMenuStrip1.Show(Cursor.Position.X, Cursor.Position.Y);
}



如果根据使用的按钮需要不同的菜单,可能需要稍微调整一下。



关于菜单名称在任务栏中显示的位 - 请确保您没有在控制面板中勾选始终在任务栏上显示所有图标和通知选项\\所有控制面板项目\通知区域图标


You might have to fiddle with it a bit if you want different menus depending on which button was used.

As to the bit where the menu name is showing in the task bar - make sure you don't have the option "Always show all icons and notifications on the taskbar" ticked in Control Panel\All Control Panel Items\Notification Area Icons