تو InitializeCoomponent بنویس:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager( ; typeof( Form1 ) );
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon( this.components );
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip( this.components );
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
//
// notifyIcon1
//
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ( (System.Drawing.Icon) ( resources.GetObject( "notifyIcon1.Icon" ) ) );
this.notifyIcon1.Visible = true;
//
// contextMenuStrip1
//
this.contextMenuStrip1.AllowDrop = true;
this.contextMenuStrip1.Items.AddRange( new System.Windows.Forms.ToolStripItem[] {
this.closeToolStripMenuItem
} );
this.contextMenuStrip1.Location = new System.Drawing.Point( 23, 61 );
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size( 122, 52 );
this.contextMenuStrip1.Visible = true;
//
// closeToolStripMenuItem
//
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
this.closeToolStripMenuItem.SettingsKey = "Form1.closeToolStripMenuItem";
this.closeToolStripMenuItem.Text = "&Close";
this.closeToolStripMenuItem.Click += new System.EventHandler( this.closeToolStripMenuItem_Click );
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size( 5, 14 );
this.ClientSize = new System.Drawing.Size( 292, 266 );
this.Name = "Form1";
this.Text = "Form1";
this.contextMenuStrip1.ResumeLayout( false );
}
و متد زیر رو هم به کدت اضافه کن.
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}