所以..我在谷歌上到处搜索,我看到了创建这个的不同方法..
但到目前为止,我还没有设法制作一个单一的工作菜单。
所以我想问一下,如何创建一个notifyIcon菜单?..(最好详细解释,因为我对此很陌生)
哪种方式最好,我应该使用哪种方式..(到目前为止,人们似乎总体上喜欢 contextmenu,但我能找到的只是 contextmenustrip,不确定它是否相同。)
目前我得到了一个表格,设置为 visible = false
, windowstate minimized
, showintaskbar = false
.
这就是目前的全部内容。我想在更广泛之前先吃菜单。
感谢您为此付出的时间和精力(不确定它是否正确制定)
编辑:我似乎设法制作了一个菜单,但是我如何让它“出现”在我的通知图标上,它是一个 ContextMenu o_o
最佳答案
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TrayTest.events
{
public partial class TrayMenu : Form
{
public TrayMenu()
{
InitializeComponent();
TrayMenuContext();
}
private void TrayMenuContext()
{
this.notify_icon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
this.notify_icon.ContextMenuStrip.Items.Add("Test1", null, this.MenuTest1_Click);
this.notify_icon.ContextMenuStrip.Items.Add("Test2", null, this.MenuTest2_Click);
this.notify_icon.ContextMenuStrip.Items.Add("Exit", null, this.MenuExit_Click);
}
void MenuTest1_Click(object sender, EventArgs e)
{
Application.Exit();
}
void MenuTest2_Click(object sender, EventArgs e)
{
Application.Exit();
}
void MenuExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
这对我来说很好。所以我就把它留在这里,让其他人看到它..(这是我的 Form1,只是用不同的名字制作了 1,它在一个名为 events 的文件夹中(有点为什么它有那个 .events))
关于c# - 如何为notifyicon 制作菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26899474/