我想以编程方式向我的托盘图标添加一个上下文菜单,这样当我右键单击托盘图标时,它应该显示我应该为托盘图标编写右键单击事件处理程序的menu.How?
我已经尝试过以下几种方法:
private void Icon_MouseRightClick(object sender, MouseButtonEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left) // shows error ate button
{
return;
}
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
// code for adding context menu
}
}宣布文森德勒为
NotifyIcon.MouseRightClick += new MouseButtonEventHandler(NotifyIcon_MouseRightClick);发布于 2013-07-30 20:13:01
右键单击上下文菜单是自动的,不需要处理它。只需构建菜单并将其分配给NotifyIcon.ContextMenu即可。
https://stackoverflow.com/questions/17946380
复制相似问题