Form1.ActiveForm.ShowInTaskbar=false;

解决方案 »

  1.   

    protected override void OnResize(EventArgs e)
    {
        base.OnResize(e);
        if(this.WindowState==FormWindowState.Minimized)
            this.Hide();
    }
      

  2.   

    using System;
    using System.Drawing;
    using System.Windows.Forms;namespace myTray
    {
    class tray : Form
    {
    private NotifyIcon ni ;
    private ContextMenu cm ;
    private MenuItem mi ;
    private System.ComponentModel.Container components;

    public static void Main(string[] Args)
    {
    Application.Run(new tray());
    }
    public tray()
    {
    this.cm = new ContextMenu();
    this.components = new System.ComponentModel.Container(); this.mi = new MenuItem("S&how");
    this.mi.Click += new EventHandler(this.showapp);
    this.cm.MenuItems.Add(this.mi); this.mi = new MenuItem("E&xit");
    this.mi.Click += new EventHandler(this.exitapp);
    this.cm.MenuItems.Add(this.mi);

    this.ni = new NotifyIcon( components );
    this.ni.ContextMenu = this.cm ;//这里准备个图标Icon,不然任务栏里看不到。
    this.ni.Icon = new Icon("image/cd.ico");
    this.ni.Visible = true ;
    }
    private void showapp(object sender, EventArgs e)
    {
    this.Show();
    }
    private void exitapp(object sender, EventArgs e)
    {
    Application.Exit();
    } protected override void OnDeactivate( EventArgs e)
    {
    this.Hide();
    }
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }
    }
    }