我是想这样:notifyIcon not1=new notifyIcon;           this.Controls.Add(not1);
但是不好用呀,

解决方案 »

  1.   

    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;
      

  2.   

    楼主的代码能编译通过吗
    添加NotifyIcon 后,要为NotifyIcon的属性Icon添加一个icon图标,并将其Visible属性设为trueNotifyIcon not1 = new NotifyIcon();
    not1.Icon = new Icon("E:\\notepad.ico");
    not1.Visible = true;
      

  3.   

    现在那个控都已经好用了,但是我想把它用代码,写出来,可是在把它向体上加时就出问题了,平时加控都是用
    this.Controls.Add(not1);这个方法但这次不好用了
      

  4.   

    NotifyIcon是不能这么用的,你直接拖个NotifyIcon 控件它也不会显示在Form窗口里,你又怎么能用Controls.Add()方法呢如果想用代码写就按照我上面的写法就行了
      

  5.   

    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);
      

  6.   

    this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
    this.notifyIcon1.ContextMenu = 你的右键菜单;
    this.notifyIcon1.Icon = 你的icon
    this.notifyIcon1.Text = "哈哈";