如何将代码System.ComponentModel.Container添加到form1?出现歧义错误

时间:2016-02-24 21:04:26

标签: c# .net winforms

在form1的顶部我添加了:

private System.ComponentModel.IContainer components;

然后在我创建的私有方法中我做了:

private void NotifyIconSettings()
        {
            this.components = new System.ComponentModel.Container();
        }

但我收到了错误:on the this.components

this.components = new System.ComponentModel.Container();

错误1' Pop3_Emails.Form1.components'之间的歧义和' Pop3_Emails.Form1.components'

我不想使用Pop3_Emails.Form1.components

更新

我现在尝试的是添加了form1构造函数:

contextMenu1.MenuItems.Add("&Open Application");
contextMenu1.MenuItems.Add("S&uspend Application");
contextMenu1.MenuItems.Add("E&xit");
notifyIcon1.Visible = true;
notifyIcon1.Text = "Right-click me!";
notifyIcon1.ContextMenu = contextMenu1;

所以现在右键单击托盘图标中的图标我看到菜单但是如何添加点击事件并处理每个菜单项?我的意思是当我点击退出所以程序将退出。现在它什么也没做。

0 个答案:

没有答案