我想在窗体上用代码添加一个notifyIcon该怎么添加呀
我是想这样:notifyIcon   not1=new   notifyIcon;   
                                  this.Controls.Add(not1); 
 但是不好用呀,
------解决方案--------------------private System.Windows.Forms.NotifyIcon notifyIcon1; 
   private System.Windows.Forms.MenuItem[] mMenuItems = new MenuItem[1]; 
   notifyIcon1 = new System.Windows.Forms.NotifyIcon(); 
             notifyIcon1.Icon = mSmileIcon; 
             notifyIcon1.Text =  "在功能表上按一下滑鼠右鍵 "; 
             notifyIcon1.Visible = true;   
             //將所有 MenuItem 物件插入陣列並且同時將它們加入到內容功能表。 
                        mMenuItems[0] = new MenuItem( "結束 ", new EventHandler(this.ExitSelect));   
             System.Windows.Forms.ContextMenu notifyiconMnu = new ContextMenu(mMenuItems); 
             notifyIcon1.ContextMenu = notifyiconMnu;
------解决方案--------------------楼主的代码能编译通过吗 
 添加NotifyIcon 后,要为NotifyIcon的属性Icon添加一个icon图标,并将其Visible属性设为true   
 NotifyIcon not1 = new NotifyIcon(); 
 not1.Icon = new Icon( "E:\\notepad.ico "); 
 not1.Visible = true;
------解决方案--------------------NotifyIcon是不能这么用的,你直接拖个NotifyIcon 控件它也不会显示在Form窗口里,你又怎么能用Controls.Add()方法呢   
 如果想用代码写就按照我上面的写法就行了
------解决方案--------------------NotifyIcon不是从Control继承来的,所以不能用Controls.Add方法添加到窗体中, 
 在窗体的代码里,你可以找到这么一句话: 
  private System.ComponentModel.IContainer components = null;   
 你可以用这个components 做为NotifyIcon的容器,而不是通过Controls.Add添加: 
 // Create the NotifyIcon. 
   this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 
------解决方案--------------------this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 
 this.notifyIcon1.ContextMenu = 你的右键菜单; 
 this.notifyIcon1.Icon = 你的icon 
 this.notifyIcon1.Text =  "哈哈 ";