Csharp/C Sharp/GUI Windows Form/StatusBar — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 11:33, 26 мая 2010

Add icon to statusbar

   using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  
  internal struct TheFontSize
  {
    public static int Huge = 30;
    public static int Normal = 20;
    public static int Tiny = 8;
  }
  
  public class mainForm : System.Windows.Forms.Form
  {
    Color currColor = Color.MistyRose;
    private int currFontSize = TheFontSize.Normal;
    private StatusBarPanel sbPnlPrompt = new StatusBarPanel();
    private StatusBarPanel sbPnlTime = new StatusBarPanel();
    private MainMenu mainMenu = new MainMenu();
    
    private MenuItem currentCheckedItem;
    private MenuItem checkedHuge;
    private MenuItem checkedNormal;
    private MenuItem checkedTiny;

    public mainForm()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.MenuComplete += new EventHandler(StatusForm_MenuDone);
      BuildMenuSystem();
      BuildStatBar();
    }
    static void Main() 
    {
      Application.Run(new mainForm());
    }
    private void FileExit_Clicked(object sender, EventArgs e) 
    {
      Console.WriteLine("File | Exit Menu item handler");
      this.Close();
    }
    private void FileSave_Clicked(object sender, EventArgs e) 
    {
            Console.WriteLine("File | Save Menu item handler");
    }
    private void ColorItem_Clicked(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string color = miClicked.Text.Remove(0,1);
      
      this.BackColor = Color.FromName(color);
      currColor = this.BackColor;
    }
    private void PopUp_Clicked(object sender, EventArgs e) 
    {
      currentCheckedItem.Checked = false;
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text;
      
      if(item == "Huge") {
        currFontSize = TheFontSize.Huge;
        currentCheckedItem = checkedHuge;
      }else if(item == "Normal") {
        currFontSize = TheFontSize.Normal;
        currentCheckedItem = checkedNormal;
      }else if(item == "Tiny") {
        currFontSize = TheFontSize.Tiny;
        currentCheckedItem = checkedTiny;
      }
      currentCheckedItem.Checked = true;
      Invalidate();
    }
    protected override void OnPaint(PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      g.DrawString("www.nfex.ru", 
        new Font("Times New Roman", (float)currFontSize), 
        new SolidBrush(Color.Black), 
        this.DisplayRectangle);
    }
    
    protected override void OnResize(EventArgs e)
    {
      base.OnResize(e);
      Invalidate();
    }
    private void HelpAbout_Clicked(object sender, EventArgs e) 
    {
      Console.WriteLine("The amazing final app...", "About...");
    }
        
    private void FileMenuItem_Selected(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text.Remove(0,1);
      
      if(item == "Save..."){
        sbPnlPrompt.Text = "Save current settings.";     
      }else{
        sbPnlPrompt.Text = "Terminates this app.";     
        } 
    }
    private void ColorMenuItem_Selected(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text.Remove(0,1);
      sbPnlPrompt.Text = "Select " + item;            
    }
    private void HelpAbout_Selected(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Displays app info";
    }
    private void StatusForm_MenuDone(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Ready";
    }
    private void timer1_Tick(object sender, EventArgs e) 
    {
      DateTime t = DateTime.Now;
      string s = t.ToLongTimeString() ;
      sbPnlTime.Text = s ;    
    }
    private void BuildMenuSystem()
    {
      MenuItem miFile = mainMenu.MenuItems.Add("&File");           
      miFile.MenuItems.Add(new MenuItem("&Save...", new EventHandler(this.FileSave_Clicked), Shortcut.CtrlS));     
      miFile.MenuItems.Add(new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX));
      miFile.MenuItems[0].Select += new EventHandler(FileMenuItem_Selected);
      miFile.MenuItems[1].Select += new EventHandler(FileMenuItem_Selected);
      MenuItem miColor = mainMenu.MenuItems.Add("&Background Color");
      miColor.MenuItems.Add("&DarkGoldenrod", new EventHandler(ColorItem_Clicked));
      miColor.MenuItems.Add("&GreenYellow", new EventHandler(ColorItem_Clicked));
      
      for(int i = 0; i < miColor.MenuItems.Count; i++){
        miColor.MenuItems[i].Select += new EventHandler(ColorMenuItem_Selected);
            }
      MenuItem miHelp = mainMenu.MenuItems.Add("Help");  
      miHelp.MenuItems.Add(new MenuItem("&About", new EventHandler(this.HelpAbout_Clicked), Shortcut.CtrlA));
      miHelp.MenuItems[0].Select += new EventHandler(HelpAbout_Selected);
      this.Menu = mainMenu;  
            ContextMenu popUpMenu = new ContextMenu();
      popUpMenu.MenuItems.Add("Huge", new EventHandler(PopUp_Clicked));
      popUpMenu.MenuItems.Add("Normal", new EventHandler(PopUp_Clicked));
      popUpMenu.MenuItems.Add("Tiny", new EventHandler(PopUp_Clicked));
      this.ContextMenu = popUpMenu;
      checkedHuge = this.ContextMenu.MenuItems[0];
      checkedNormal = this.ContextMenu.MenuItems[1];        
      checkedTiny = this.ContextMenu.MenuItems[2];
      
      if(currFontSize == TheFontSize.Huge)
        currentCheckedItem = checkedHuge;
      else if(currFontSize == TheFontSize.Normal)
        currentCheckedItem = checkedNormal;
      else
        currentCheckedItem = checkedTiny;
      currentCheckedItem.Checked = true;
    }
    private void BuildStatBar()
    {
        Timer timer1 = new Timer();
      timer1.Interval = 1000;
      timer1.Enabled = true;
      timer1.Tick += new EventHandler(timer1_Tick);
        StatusBar statusBar = new StatusBar();
        
      statusBar.ShowPanels = true;
      statusBar.Panels.AddRange((StatusBarPanel[])new StatusBarPanel[] {sbPnlPrompt, sbPnlTime});
      sbPnlPrompt.BorderStyle = StatusBarPanelBorderStyle.None;
      sbPnlPrompt.AutoSize = StatusBarPanelAutoSize.Spring;
      sbPnlPrompt.Width = 62;
      sbPnlPrompt.Text = "Ready";
      sbPnlTime.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
      sbPnlTime.Width = 76;
      try
      {
        Icon i = new Icon("icon1.ico");
        sbPnlPrompt.Icon = i;
      } catch(Exception e) {
        MessageBox.Show(e.Message);
      }
      this.Controls.Add(statusBar);  
    }
  }


Add StatusPanels to StatusBar

 
using System;
using System.Drawing;
using System.Windows.Forms;
   
class TwoStatusBarPanels: Form
{
     public static void Main()
     {
          Application.Run(new TwoStatusBarPanels());
     }
     public TwoStatusBarPanels()
     {
          Text = "Two Status Bar Panels";
          StatusBar sb = new StatusBar();
          sb.Parent = this;
          sb.ShowPanels = true;
   
          StatusBarPanel sbpanel1 = new StatusBarPanel();
          sbpanel1.Text = "Panel 1";
   
          StatusBarPanel sbpanel2 = new StatusBarPanel();
          sbpanel2.Text = "Panel 2";
   
          sb.Panels.Add(sbpanel1);
          sb.Panels.Add(sbpanel2);
     }
}


Display current time on statusbar

   using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  
  internal struct TheFontSize
  {
    public static int Huge = 30;
    public static int Normal = 20;
    public static int Tiny = 8;
  }
  
  public class mainForm : System.Windows.Forms.Form
  {
    Color currColor = Color.MistyRose;
    private int currFontSize = TheFontSize.Normal;
    private StatusBarPanel sbPnlPrompt = new StatusBarPanel();
    private StatusBarPanel sbPnlTime = new StatusBarPanel();
    private MainMenu mainMenu = new MainMenu();
    
    private MenuItem currentCheckedItem;
    private MenuItem checkedHuge;
    private MenuItem checkedNormal;
    private MenuItem checkedTiny;

    public mainForm()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.MenuComplete += new EventHandler(StatusForm_MenuDone);
      BuildMenuSystem();
      BuildStatBar();
    }
    static void Main() 
    {
      Application.Run(new mainForm());
    }
    private void FileExit_Clicked(object sender, EventArgs e) 
    {
      Console.WriteLine("File | Exit Menu item handler");
      this.Close();
    }
    private void FileSave_Clicked(object sender, EventArgs e) 
    {
            Console.WriteLine("File | Save Menu item handler");
    }
    private void ColorItem_Clicked(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string color = miClicked.Text.Remove(0,1);
      
      this.BackColor = Color.FromName(color);
      currColor = this.BackColor;
    }
    private void PopUp_Clicked(object sender, EventArgs e) 
    {
      currentCheckedItem.Checked = false;
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text;
      
      if(item == "Huge") {
        currFontSize = TheFontSize.Huge;
        currentCheckedItem = checkedHuge;
      }else if(item == "Normal") {
        currFontSize = TheFontSize.Normal;
        currentCheckedItem = checkedNormal;
      }else if(item == "Tiny") {
        currFontSize = TheFontSize.Tiny;
        currentCheckedItem = checkedTiny;
      }
      currentCheckedItem.Checked = true;
      Invalidate();
    }
    protected override void OnPaint(PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      g.DrawString("www.nfex.ru", 
        new Font("Times New Roman", (float)currFontSize), 
        new SolidBrush(Color.Black), 
        this.DisplayRectangle);
    }
    
    protected override void OnResize(EventArgs e)
    {
      base.OnResize(e);
      Invalidate();
    }
    private void HelpAbout_Clicked(object sender, EventArgs e) 
    {
      Console.WriteLine("The amazing final app...", "About...");
    }
        
    private void FileMenuItem_Selected(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text.Remove(0,1);
      
      if(item == "Save..."){
        sbPnlPrompt.Text = "Save current settings.";     
      }else{
        sbPnlPrompt.Text = "Terminates this app.";     
        } 
    }
    private void ColorMenuItem_Selected(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text.Remove(0,1);
      sbPnlPrompt.Text = "Select " + item;            
    }
    private void HelpAbout_Selected(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Displays app info";
    }
    private void StatusForm_MenuDone(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Ready";
    }
    private void timer1_Tick(object sender, EventArgs e) 
    {
      DateTime t = DateTime.Now;
      string s = t.ToLongTimeString() ;
      sbPnlTime.Text = s ;    
    }
    private void BuildMenuSystem()
    {
      MenuItem miFile = mainMenu.MenuItems.Add("&File");           
      miFile.MenuItems.Add(new MenuItem("&Save...", new EventHandler(this.FileSave_Clicked), Shortcut.CtrlS));     
      miFile.MenuItems.Add(new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX));
      miFile.MenuItems[0].Select += new EventHandler(FileMenuItem_Selected);
      miFile.MenuItems[1].Select += new EventHandler(FileMenuItem_Selected);
      MenuItem miColor = mainMenu.MenuItems.Add("&Background Color");
      miColor.MenuItems.Add("&DarkGoldenrod", new EventHandler(ColorItem_Clicked));
      miColor.MenuItems.Add("&GreenYellow", new EventHandler(ColorItem_Clicked));
      
      for(int i = 0; i < miColor.MenuItems.Count; i++){
        miColor.MenuItems[i].Select += new EventHandler(ColorMenuItem_Selected);
            }
      MenuItem miHelp = mainMenu.MenuItems.Add("Help");  
      miHelp.MenuItems.Add(new MenuItem("&About", new EventHandler(this.HelpAbout_Clicked), Shortcut.CtrlA));
      miHelp.MenuItems[0].Select += new EventHandler(HelpAbout_Selected);
      this.Menu = mainMenu;  
            ContextMenu popUpMenu = new ContextMenu();
      popUpMenu.MenuItems.Add("Huge", new EventHandler(PopUp_Clicked));
      popUpMenu.MenuItems.Add("Normal", new EventHandler(PopUp_Clicked));
      popUpMenu.MenuItems.Add("Tiny", new EventHandler(PopUp_Clicked));
      this.ContextMenu = popUpMenu;
      checkedHuge = this.ContextMenu.MenuItems[0];
      checkedNormal = this.ContextMenu.MenuItems[1];        
      checkedTiny = this.ContextMenu.MenuItems[2];
      
      if(currFontSize == TheFontSize.Huge)
        currentCheckedItem = checkedHuge;
      else if(currFontSize == TheFontSize.Normal)
        currentCheckedItem = checkedNormal;
      else
        currentCheckedItem = checkedTiny;
      currentCheckedItem.Checked = true;
    }
    private void BuildStatBar()
    {
        Timer timer1 = new Timer();
      timer1.Interval = 1000;
      timer1.Enabled = true;
      timer1.Tick += new EventHandler(timer1_Tick);
        StatusBar statusBar = new StatusBar();
        
      statusBar.ShowPanels = true;
      statusBar.Panels.AddRange((StatusBarPanel[])new StatusBarPanel[] {sbPnlPrompt, sbPnlTime});
      sbPnlPrompt.BorderStyle = StatusBarPanelBorderStyle.None;
      sbPnlPrompt.AutoSize = StatusBarPanelAutoSize.Spring;
      sbPnlPrompt.Width = 62;
      sbPnlPrompt.Text = "Ready";
      sbPnlTime.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
      sbPnlTime.Width = 76;
      try
      {
        Icon i = new Icon("icon1.ico");
        sbPnlPrompt.Icon = i;
      } catch(Exception e) {
        MessageBox.Show(e.Message);
      }
      this.Controls.Add(statusBar);  
    }
  }


Display menu item alert message on the statusbar

   using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  
  internal struct TheFontSize
  {
    public static int Huge = 30;
    public static int Normal = 20;
    public static int Tiny = 8;
  }
  
  public class mainForm : System.Windows.Forms.Form
  {
    Color currColor = Color.MistyRose;
    private int currFontSize = TheFontSize.Normal;
    private StatusBarPanel sbPnlPrompt = new StatusBarPanel();
    private StatusBarPanel sbPnlTime = new StatusBarPanel();
    private MainMenu mainMenu = new MainMenu();
    
    private MenuItem currentCheckedItem;
    private MenuItem checkedHuge;
    private MenuItem checkedNormal;
    private MenuItem checkedTiny;

    public mainForm()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.MenuComplete += new EventHandler(StatusForm_MenuDone);
      BuildMenuSystem();
      BuildStatBar();
    }
    static void Main() 
    {
      Application.Run(new mainForm());
    }
    private void FileExit_Clicked(object sender, EventArgs e) 
    {
      Console.WriteLine("File | Exit Menu item handler");
      this.Close();
    }
    private void FileSave_Clicked(object sender, EventArgs e) 
    {
            Console.WriteLine("File | Save Menu item handler");
    }
    private void ColorItem_Clicked(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string color = miClicked.Text.Remove(0,1);
      
      this.BackColor = Color.FromName(color);
      currColor = this.BackColor;
    }
    private void PopUp_Clicked(object sender, EventArgs e) 
    {
      currentCheckedItem.Checked = false;
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text;
      
      if(item == "Huge") {
        currFontSize = TheFontSize.Huge;
        currentCheckedItem = checkedHuge;
      }else if(item == "Normal") {
        currFontSize = TheFontSize.Normal;
        currentCheckedItem = checkedNormal;
      }else if(item == "Tiny") {
        currFontSize = TheFontSize.Tiny;
        currentCheckedItem = checkedTiny;
      }
      currentCheckedItem.Checked = true;
      Invalidate();
    }
    protected override void OnPaint(PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      g.DrawString("www.nfex.ru", 
        new Font("Times New Roman", (float)currFontSize), 
        new SolidBrush(Color.Black), 
        this.DisplayRectangle);
    }
    
    protected override void OnResize(EventArgs e)
    {
      base.OnResize(e);
      Invalidate();
    }
    private void HelpAbout_Clicked(object sender, EventArgs e) 
    {
      Console.WriteLine("The amazing final app...", "About...");
    }
        
    private void FileMenuItem_Selected(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text.Remove(0,1);
      
      if(item == "Save..."){
        sbPnlPrompt.Text = "Save current settings.";     
      }else{
        sbPnlPrompt.Text = "Terminates this app.";     
        } 
    }
    private void ColorMenuItem_Selected(object sender, EventArgs e) 
    {
      MenuItem miClicked = (MenuItem)sender;
      string item = miClicked.Text.Remove(0,1);
      sbPnlPrompt.Text = "Select " + item;            
    }
    private void HelpAbout_Selected(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Displays app info";
    }
    private void StatusForm_MenuDone(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Ready";
    }
    private void timer1_Tick(object sender, EventArgs e) 
    {
      DateTime t = DateTime.Now;
      string s = t.ToLongTimeString() ;
      sbPnlTime.Text = s ;    
    }
    private void BuildMenuSystem()
    {
      MenuItem miFile = mainMenu.MenuItems.Add("&File");           
      miFile.MenuItems.Add(new MenuItem("&Save...", new EventHandler(this.FileSave_Clicked), Shortcut.CtrlS));     
      miFile.MenuItems.Add(new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX));
      miFile.MenuItems[0].Select += new EventHandler(FileMenuItem_Selected);
      miFile.MenuItems[1].Select += new EventHandler(FileMenuItem_Selected);
      MenuItem miColor = mainMenu.MenuItems.Add("&Background Color");
      miColor.MenuItems.Add("&DarkGoldenrod", new EventHandler(ColorItem_Clicked));
      miColor.MenuItems.Add("&GreenYellow", new EventHandler(ColorItem_Clicked));
      
      for(int i = 0; i < miColor.MenuItems.Count; i++){
        miColor.MenuItems[i].Select += new EventHandler(ColorMenuItem_Selected);
            }
      MenuItem miHelp = mainMenu.MenuItems.Add("Help");  
      miHelp.MenuItems.Add(new MenuItem("&About", new EventHandler(this.HelpAbout_Clicked), Shortcut.CtrlA));
      miHelp.MenuItems[0].Select += new EventHandler(HelpAbout_Selected);
      this.Menu = mainMenu;  
            ContextMenu popUpMenu = new ContextMenu();
      popUpMenu.MenuItems.Add("Huge", new EventHandler(PopUp_Clicked));
      popUpMenu.MenuItems.Add("Normal", new EventHandler(PopUp_Clicked));
      popUpMenu.MenuItems.Add("Tiny", new EventHandler(PopUp_Clicked));
      this.ContextMenu = popUpMenu;
      checkedHuge = this.ContextMenu.MenuItems[0];
      checkedNormal = this.ContextMenu.MenuItems[1];        
      checkedTiny = this.ContextMenu.MenuItems[2];
      
      if(currFontSize == TheFontSize.Huge)
        currentCheckedItem = checkedHuge;
      else if(currFontSize == TheFontSize.Normal)
        currentCheckedItem = checkedNormal;
      else
        currentCheckedItem = checkedTiny;
      currentCheckedItem.Checked = true;
    }
    private void BuildStatBar()
    {
        Timer timer1 = new Timer();
      timer1.Interval = 1000;
      timer1.Enabled = true;
      timer1.Tick += new EventHandler(timer1_Tick);
        StatusBar statusBar = new StatusBar();
        
      statusBar.ShowPanels = true;
      statusBar.Panels.AddRange((StatusBarPanel[])new StatusBarPanel[] {sbPnlPrompt, sbPnlTime});
      sbPnlPrompt.BorderStyle = StatusBarPanelBorderStyle.None;
      sbPnlPrompt.AutoSize = StatusBarPanelAutoSize.Spring;
      sbPnlPrompt.Width = 62;
      sbPnlPrompt.Text = "Ready";
      sbPnlTime.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
      sbPnlTime.Width = 76;
      try
      {
        Icon i = new Icon("icon1.ico");
        sbPnlPrompt.Icon = i;
      } catch(Exception e) {
        MessageBox.Show(e.Message);
      }
      this.Controls.Add(statusBar);  
    }
  }


Display message in StatusBar

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
  private System.Windows.Forms.GroupBox groupBox1;
  private System.Windows.Forms.ruboBox lstFonts;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.StatusStrip statusBar;
  private System.Windows.Forms.ToolStripStatusLabel statusLabel;
  public Form1() {
        InitializeComponent();
    System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
    foreach (FontFamily family in fonts.Families)
    {
      lstFonts.Items.Add(family.Name);
    }
  }
  private void lstFonts_SelectedIndexChanged(object sender, EventArgs e)
  {
        this.Invalidate();
  }
  private void Form1_Paint(object sender, PaintEventArgs e)
  {
    if (lstFonts.SelectedIndex != -1)
    {
            e.Graphics.DrawString(lstFonts.Text, new Font(lstFonts.Text, 50), Brushes.Black, 10, 50);
            statusBar.Items[0].Text = lstFonts.Text;
    }
  }
  private void InitializeComponent()
  {
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.lstFonts = new System.Windows.Forms.ruboBox();
    this.label1 = new System.Windows.Forms.Label();
    this.statusBar = new System.Windows.Forms.StatusStrip();
    this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
    this.groupBox1.SuspendLayout();
    this.statusBar.SuspendLayout();
    this.SuspendLayout();
    // 
    // groupBox1
    // 
    this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
          | System.Windows.Forms.AnchorStyles.Right)));
    this.groupBox1.Controls.Add(this.lstFonts);
    this.groupBox1.Controls.Add(this.label1);
    this.groupBox1.Location = new System.Drawing.Point(7, 0);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(497, 40);
    this.groupBox1.TabIndex = 1;
    this.groupBox1.TabStop = false;
    // 
    // lstFonts
    // 
    this.lstFonts.DropDownStyle = System.Windows.Forms.ruboBoxStyle.DropDownList;
    this.lstFonts.DropDownWidth = 340;
    this.lstFonts.FormattingEnabled = true;
    this.lstFonts.Location = new System.Drawing.Point(100, 12);
    this.lstFonts.Name = "lstFonts";
    this.lstFonts.Size = new System.Drawing.Size(340, 21);
    this.lstFonts.TabIndex = 1;
    this.lstFonts.SelectedIndexChanged += new System.EventHandler(this.lstFonts_SelectedIndexChanged);
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(12, 16);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(80, 12);
    this.label1.TabIndex = 0;
    this.label1.Text = "Choose Font:";
    // 
    // statusBar
    // 
    this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.statusLabel});
    this.statusBar.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Table;
    this.statusBar.Location = new System.Drawing.Point(0, 155);
    this.statusBar.Name = "statusBar";
    this.statusBar.Size = new System.Drawing.Size(516, 22);
    this.statusBar.TabIndex = 2;
    this.statusBar.Text = "statusStrip1";
    // 
    // statusLabel
    // 
    this.statusLabel.Name = "statusLabel";
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(516, 177);
    this.Controls.Add(this.groupBox1);
    this.Controls.Add(this.statusBar);
    this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.Text = "Font Viewer";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.groupBox1.ResumeLayout(false);
    this.statusBar.ResumeLayout(false);
    this.ResumeLayout(false);
    this.PerformLayout();
  }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


Set Text to Statusbar

 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class SimpleStatusBar: Form
{
     public static void Main()
     {
          Application.Run(new SimpleStatusBar());
     }
     public SimpleStatusBar()
     {
          Text = "Simple Status Bar";
          ResizeRedraw = true;
   
          StatusBar sb = new StatusBar();
          sb.Parent = this;
          sb.Text = "My initial status bar text";
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics grfx = pea.Graphics;
          Pen      pen  = new Pen(ForeColor);
   
          grfx.DrawLine(pen, 0, 0, ClientSize.Width, ClientSize.Height);
          grfx.DrawLine(pen, ClientSize.Width, 0, 0, ClientSize.Height);
     }
}


Status bar: display time and prompt message for menu item

  using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  public class MainForm : System.Windows.Forms.Form
  {
    private StatusBar statusBar = new StatusBar();
    private StatusBarPanel sbPnlPrompt = new StatusBarPanel();
    private StatusBarPanel sbPnlTime = new StatusBarPanel();
    private Timer timer1 = new Timer();
    private MainMenu mainMenu;
    private System.ruponentModel.Container components;
    public MainForm()
    {
      InitializeComponent();
      Text = "Status Bar Example";
      CenterToScreen();
      BackColor = Color.CadetBlue;
      // Configure the timer.
      timer1.Interval = 1000;
      timer1.Enabled = true;
      timer1.Tick += new EventHandler(timer1_Tick);
      this.MenuComplete += new EventHandler(StatusForm_MenuDone);
      BuildMenuSystem();
      BuildStatBar();
    }
    private void InitializeComponent()
    {
      this.ruponents = new System.ruponentModel.Container();
      this.Size = new System.Drawing.Size(300,300);
      this.Text = "Form1";
    }
    static void Main() 
    {
      Application.Run(new MainForm());
    }
    // Clicked handlers.
    private void FileExit_Clicked(object sender, EventArgs e) 
    {    
      this.Close();
    }
        
    // Help | About Menu item handler
    private void HelpAbout_Clicked(object sender, EventArgs e) 
    {
      MessageBox.Show("The amazing menu app...");
    }
        
    // Selected handlers.
    private void FileExit_Selected(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Terminates this app";     
    }
    private void HelpAbout_Selected(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Displays app info";
    }
    // Other handlers...
    private void StatusForm_MenuDone(object sender, EventArgs e) 
    {
      sbPnlPrompt.Text = "Ready";
    }
    private void timer1_Tick(object sender, EventArgs e) 
    {
      DateTime t = DateTime.Now;
      string s = t.ToLongTimeString() ;
      sbPnlTime.Text = s ;    
    }
    private void BuildMenuSystem()
    {
      mainMenu = new MainMenu();
      
      MenuItem miFile = mainMenu.MenuItems.Add("&File");          
      miFile.MenuItems.Add(new MenuItem("E&xit",new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX));
      miFile.MenuItems[0].Select += new EventHandler(FileExit_Selected);
      MenuItem miHelp = mainMenu.MenuItems.Add("Help");  
      miHelp.MenuItems.Add(new MenuItem("&About",  new EventHandler(this.HelpAbout_Clicked), Shortcut.CtrlA));
      miHelp.MenuItems[0].Select += new EventHandler(HelpAbout_Selected);
      this.Menu = mainMenu;      
    }
    private void BuildStatBar()
    {
      // Configure the status bar.
      statusBar.ShowPanels = true;
      statusBar.Panels.AddRange(new StatusBarPanel[] {sbPnlPrompt, sbPnlTime});
      
      // Configure prompt panel.
      sbPnlPrompt.BorderStyle = StatusBarPanelBorderStyle.None;
      sbPnlPrompt.AutoSize = StatusBarPanelAutoSize.Spring;
      sbPnlPrompt.Width = 62;
      sbPnlPrompt.Text = "Ready";
      
      // Configure time pane.
      sbPnlTime.Alignment = HorizontalAlignment.Right;
      sbPnlTime.Width = 76;
      try
      {
        Icon i = new Icon("status.ico");
        sbPnlPrompt.Icon = i;
      }
      catch(Exception e)
      {
        Console.WriteLine(e.Message);
      }
      this.Controls.Add(statusBar);  
    }
  }


StatusBar Example

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald
Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
namespace StatusBarExample
{
  /// <summary>
  /// Summary description for StatusBarExample.
  /// </summary>
  public class StatusBarExample : System.Windows.Forms.Form
  {
    internal System.Windows.Forms.StatusBar statusBar;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ruponentModel.Container components = null;
    public StatusBarExample()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();
      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if (components != null) 
        {
          components.Dispose();
        }
      }
      base.Dispose( disposing );
    }
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.statusBar = new System.Windows.Forms.StatusBar();
      this.SuspendLayout();
      // 
      // statusBar
      // 
      this.statusBar.Location = new System.Drawing.Point(0, 138);
      this.statusBar.Name = "statusBar";
      this.statusBar.ShowPanels = true;
      this.statusBar.Size = new System.Drawing.Size(292, 24);
      this.statusBar.SizingGrip = false;
      this.statusBar.TabIndex = 1;
      // 
      // StatusBarExample
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
      this.ClientSize = new System.Drawing.Size(292, 162);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.statusBar});
      this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.Name = "StatusBarExample";
      this.Text = "StatusBar Example";
      this.Load += new System.EventHandler(this.StatusBarExample_Load);
      this.ResumeLayout(false);
    }
    #endregion
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
      Application.Run(new StatusBarExample());
    }
    private void StatusBarExample_Load(object sender, System.EventArgs e)
    {
      StatusBarPanel pnlStatus = new StatusBarPanel();
      pnlStatus.Text = "Ready";
      pnlStatus.Icon = new Icon(Application.StartupPath + "\\active.ico");
      pnlStatus.AutoSize = StatusBarPanelAutoSize.Contents;
      StatusBarPanel pnlConnection = new StatusBarPanel();
      pnlConnection.Text = "Connected to " + "localhost";
      pnlConnection.AutoSize = StatusBarPanelAutoSize.Spring;
      statusBar.Panels.Add(pnlStatus);
      statusBar.Panels.Add(pnlConnection);
    }
  }
}

<A href="http://www.nfex.ru/Code/CSharpDownload/StatusBarExample.zip">StatusBarExample.zip( 22 k)</a>


StatusBar with two panels

using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.RadioButton rdoLarge;
        private System.Windows.Forms.RadioButton rdoSmall;
        private System.Windows.Forms.RadioButton rdoList;
        private System.Windows.Forms.RadioButton rdoDetails;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.StatusBarPanel statusBarPanel1;
        private System.Windows.Forms.StatusBarPanel statusBarPanel2;
        private System.Windows.Forms.StatusBar sbInfo;
        public Form1()
        {
            InitializeComponent();
        }
        private void InitializeComponent()
        {
            this.rdoDetails = new System.Windows.Forms.RadioButton();
            this.sbInfo = new System.Windows.Forms.StatusBar();
            this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
            this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
            this.rdoList = new System.Windows.Forms.RadioButton();
            this.rdoLarge = new System.Windows.Forms.RadioButton();
            this.rdoSmall = new System.Windows.Forms.RadioButton();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            ((System.ruponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
            ((System.ruponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            //
            // rdoDetails
            //
            this.rdoDetails.Location = new System.Drawing.Point(8, 96);
            this.rdoDetails.Name = "rdoDetails";
            this.rdoDetails.Size = new System.Drawing.Size(104, 16);
            this.rdoDetails.TabIndex = 3;
            this.rdoDetails.Text = "Details";
            this.rdoDetails.CheckedChanged += new System.EventHandler(this.rdoDetails_CheckedChanged);
            //
            // sbInfo
            //
            this.sbInfo.Location = new System.Drawing.Point(0, 277);
            this.sbInfo.Name = "sbInfo";
            this.sbInfo.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
                                                                                                                                                            this.statusBarPanel1,
                                                                                                                                                            this.statusBarPanel2});
            this.sbInfo.ShowPanels = true;
            this.sbInfo.Size = new System.Drawing.Size(552, 16);
            this.sbInfo.TabIndex = 3;
            //
            // statusBarPanel1
            //
            this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
            this.statusBarPanel1.Width = 526;
            //
            // statusBarPanel2
            //
            this.statusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
            this.statusBarPanel2.MinWidth = 0;
            this.statusBarPanel2.Width = 10;
            //
            // rdoList
            //
            this.rdoList.Checked = true;
            this.rdoList.Location = new System.Drawing.Point(8, 72);
            this.rdoList.Name = "rdoList";
            this.rdoList.Size = new System.Drawing.Size(104, 16);
            this.rdoList.TabIndex = 2;
            this.rdoList.TabStop = true;
            this.rdoList.Text = "List";
            this.rdoList.CheckedChanged += new System.EventHandler(this.rdoList_CheckedChanged);
            //
            // rdoLarge
            //
            this.rdoLarge.Location = new System.Drawing.Point(8, 24);
            this.rdoLarge.Name = "rdoLarge";
            this.rdoLarge.Size = new System.Drawing.Size(96, 16);
            this.rdoLarge.TabIndex = 0;
            this.rdoLarge.Text = "LargeIcon";
            this.rdoLarge.CheckedChanged += new System.EventHandler(this.rdoLarge_CheckedChanged);
            //
            // rdoSmall
            //
            this.rdoSmall.Location = new System.Drawing.Point(8, 48);
            this.rdoSmall.Name = "rdoSmall";
            this.rdoSmall.Size = new System.Drawing.Size(104, 16);
            this.rdoSmall.TabIndex = 1;
            this.rdoSmall.Text = "SmallIcon";
            this.rdoSmall.CheckedChanged += new System.EventHandler(this.rdoSmall_CheckedChanged);
            //
            // groupBox1
            //
            this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                                                                                        this.rdoDetails,
                                                                                                                                                        this.rdoList,
                                                                                                                                                        this.rdoSmall,
                                                                                                                                                        this.rdoLarge});
            this.groupBox1.Location = new System.Drawing.Point(424, 16);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(120, 128);
            this.groupBox1.TabIndex = 2;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "View mode";
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(552, 293);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {this.sbInfo,
                                                                       this.groupBox1,
                                                                       });
            this.Name = "Form1";
            this.Text = "StatusBar";
            ((System.ruponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
            ((System.ruponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
        static void Main()
        {
            Application.Run(new Form1());
        }
        private void rdoLarge_CheckedChanged(object sender, System.EventArgs e)
        {
            RadioButton rdb = (RadioButton)sender;
            if (rdb.Checked)
            {
                this.sbInfo.Panels[1].Text = "Large Icon";
            }
            this.sbInfo.Panels[0].Text = "AAA";
        }
        private void rdoList_CheckedChanged(object sender, System.EventArgs e)
        {
            RadioButton rdb = (RadioButton)sender;
            if (rdb.Checked)
            {
                this.sbInfo.Panels[1].Text = "List";
            }
            this.sbInfo.Panels[0].Text = "BBB";
        }
        private void rdoSmall_CheckedChanged(object sender, System.EventArgs e)
        {
            RadioButton rdb = (RadioButton)sender;
            if (rdb.Checked)
            {
                this.sbInfo.Panels[1].Text = "Small Icon";
            }
            this.sbInfo.Panels[0].Text = "CCC";
        }
        private void rdoDetails_CheckedChanged(object sender, System.EventArgs e)
        {
            RadioButton rdb = (RadioButton)sender;
            if (rdb.Checked)
            {
                this.sbInfo.Panels[1].Text = "Details";
            }
            this.sbInfo.Panels[0].Text = "DDD";
        }
    }


Status Strip Example

 
using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
enum DateTimeFormat {
    ShowClock,
    ShowDay
}
public class MainWindow : Form {
    DateTimeFormat dtFormat = DateTimeFormat.ShowClock;
    private ToolStripMenuItem currentCheckedItem;
    public MainWindow() {
        InitializeComponent();
        BackColor = Color.CadetBlue;
        currentCheckedItem = currentTimeToolStripMenuItem;
        currentCheckedItem.Checked = true;
    }
    private void timerDateTimeUpdate_Tick(object sender, EventArgs e) {
        string panelInfo = "";
        if (dtFormat == DateTimeFormat.ShowClock)
            panelInfo = DateTime.Now.ToLongTimeString();
        else
            panelInfo = DateTime.Now.ToLongDateString();
        toolStripStatusLabelClock.Text = panelInfo;
    }
    private void currentTimeToolStripMenuItem_Click(object sender, EventArgs e) {
        currentCheckedItem.Checked = false;
        dtFormat = DateTimeFormat.ShowClock;
        currentCheckedItem = currentTimeToolStripMenuItem;
        currentCheckedItem.Checked = true;
    }
    private void dayoftheWeekToolStripMenuItem_Click(object sender, EventArgs e) {
        currentCheckedItem.Checked = false;
        dtFormat = DateTimeFormat.ShowDay;
        currentCheckedItem = dayoftheWeekToolStripMenuItem;
        currentCheckedItem.Checked = true;
    }
    private void exitToolStripMenuItem_Click(object sender, EventArgs e) {
        Application.Exit();
    }
    private void aboutToolStripMenuItem_Click(object sender, EventArgs e) {
        MessageBox.Show("My StatusStripApp!");
    }
    private void exitToolStripMenuItem_MouseHover(object sender, EventArgs e) {
        toolStripStatusLabelMenuState.Text = "Exits the app.";
    }
    private void aboutToolStripMenuItem_MouseHover(object sender, EventArgs e) {
        toolStripStatusLabelMenuState.Text = "Shows about box.";
    }
    private void dayoftheWeekToolStripMenuItem_MouseHover(object sender, EventArgs e) {
        toolStripStatusLabelMenuState.Text = "Shows the day of the week.";
    }
    private void currentTimeToolStripMenuItem_MouseHover(object sender, EventArgs e) {
        toolStripStatusLabelMenuState.Text = "Shows the current time.";
    }
    private void SetReadyPrompt(object sender, EventArgs e) {
        toolStripStatusLabelMenuState.Text = "Ready.";
    }
    private void InitializeComponent() {
        this.mainStatusStrip = new System.Windows.Forms.StatusStrip();
        this.toolStripStatusLabelMenuState = new System.Windows.Forms.ToolStripStatusLabel();
        this.toolStripStatusLabelClock = new System.Windows.Forms.ToolStripStatusLabel();
        this.toolStripDropDownButtonDateTime = new System.Windows.Forms.ToolStripDropDownButton();
        this.dayoftheWeekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.currentTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.menuStrip1 = new System.Windows.Forms.MenuStrip();
        this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.timerDateTimeUpdate = new System.Windows.Forms.Timer();
        this.mainStatusStrip.SuspendLayout();
        this.menuStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // mainStatusStrip
        // 
        this.mainStatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripStatusLabelMenuState,
            this.toolStripStatusLabelClock,
            this.toolStripDropDownButtonDateTime});
        this.mainStatusStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Table;
        this.mainStatusStrip.Location = new System.Drawing.Point(0, 78);
        this.mainStatusStrip.Name = "mainStatusStrip";
        this.mainStatusStrip.Size = new System.Drawing.Size(361, 27);
        this.mainStatusStrip.TabIndex = 0;
        this.mainStatusStrip.Text = "statusStrip1";
        // 
        // toolStripStatusLabelMenuState
        // 
        this.toolStripStatusLabelMenuState.Name = "toolStripStatusLabelMenuState";
        this.toolStripStatusLabelMenuState.Spring = true;
        this.toolStripStatusLabelMenuState.TextAlign = System.Drawing.ContentAlignment.TopLeft;
        // 
        // toolStripStatusLabelClock
        // 
        this.toolStripStatusLabelClock.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
                    | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
                    | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
        this.toolStripStatusLabelClock.Name = "toolStripStatusLabelClock";
        // 
        // toolStripDropDownButtonDateTime
        // 
        this.toolStripDropDownButtonDateTime.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
        this.toolStripDropDownButtonDateTime.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.dayoftheWeekToolStripMenuItem,
            this.currentTimeToolStripMenuItem});
        this.toolStripDropDownButtonDateTime.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.toolStripDropDownButtonDateTime.Name = "toolStripDropDownButtonDateTime";
        this.toolStripDropDownButtonDateTime.Text = "toolStripDropDownButton1";
        // 
        // dayoftheWeekToolStripMenuItem
        // 
        this.dayoftheWeekToolStripMenuItem.Name = "dayoftheWeekToolStripMenuItem";
        this.dayoftheWeekToolStripMenuItem.Text = "Day of the Week";
        this.dayoftheWeekToolStripMenuItem.MouseLeave += new System.EventHandler(this.SetReadyPrompt);
        this.dayoftheWeekToolStripMenuItem.MouseHover += new System.EventHandler(this.dayoftheWeekToolStripMenuItem_MouseHover);
        this.dayoftheWeekToolStripMenuItem.Click += new System.EventHandler(this.dayoftheWeekToolStripMenuItem_Click);
        // 
        // currentTimeToolStripMenuItem
        // 
        this.currentTimeToolStripMenuItem.Name = "currentTimeToolStripMenuItem";
        this.currentTimeToolStripMenuItem.Text = "Current Time";
        this.currentTimeToolStripMenuItem.MouseLeave += new System.EventHandler(this.SetReadyPrompt);
        this.currentTimeToolStripMenuItem.MouseHover += new System.EventHandler(this.currentTimeToolStripMenuItem_MouseHover);
        this.currentTimeToolStripMenuItem.Click += new System.EventHandler(this.currentTimeToolStripMenuItem_Click);
        // 
        // menuStrip1
        // 
        this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem,
            this.helpToolStripMenuItem});
        this.menuStrip1.Location = new System.Drawing.Point(0, 0);
        this.menuStrip1.Name = "menuStrip1";
        this.menuStrip1.Size = new System.Drawing.Size(361, 24);
        this.menuStrip1.TabIndex = 1;
        this.menuStrip1.Text = "menuStrip1";
        // 
        // fileToolStripMenuItem
        // 
        this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.exitToolStripMenuItem});
        this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
        this.fileToolStripMenuItem.Text = "&File";
        // 
        // exitToolStripMenuItem
        // 
        this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
        this.exitToolStripMenuItem.Text = "E&xit";
        this.exitToolStripMenuItem.MouseLeave += new System.EventHandler(this.SetReadyPrompt);
        this.exitToolStripMenuItem.MouseHover += new System.EventHandler(this.exitToolStripMenuItem_MouseHover);
        this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
        // 
        // helpToolStripMenuItem
        // 
        this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.aboutToolStripMenuItem});
        this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
        this.helpToolStripMenuItem.Text = "&Help";
        // 
        // aboutToolStripMenuItem
        // 
        this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
        this.aboutToolStripMenuItem.Text = "&About";
        this.aboutToolStripMenuItem.MouseLeave += new System.EventHandler(this.SetReadyPrompt);
        this.aboutToolStripMenuItem.MouseHover += new System.EventHandler(this.aboutToolStripMenuItem_MouseHover);
        this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
        // 
        // timerDateTimeUpdate
        // 
        this.timerDateTimeUpdate.Enabled = true;
        this.timerDateTimeUpdate.Interval = 1000;
        this.timerDateTimeUpdate.Tick += new System.EventHandler(this.timerDateTimeUpdate_Tick);
        // 
        // MainWindow
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(361, 105);
        this.Controls.Add(this.mainStatusStrip);
        this.Controls.Add(this.menuStrip1);
        this.MainMenuStrip = this.menuStrip1;
        this.Name = "MainWindow";
        this.Text = "Form1";
        this.mainStatusStrip.ResumeLayout(false);
        this.menuStrip1.ResumeLayout(false);
        this.ResumeLayout(false);
        this.PerformLayout();
    }
    private System.Windows.Forms.StatusStrip mainStatusStrip;
    private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelMenuState;
    private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelClock;
    private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButtonDateTime;
    private System.Windows.Forms.MenuStrip menuStrip1;
    private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem dayoftheWeekToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem currentTimeToolStripMenuItem;
    private System.Windows.Forms.Timer timerDateTimeUpdate;
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.Run(new MainWindow());
    }
}


Use Label as status bar

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
    private System.Windows.Forms.Label lblCount;
    List<Rectangle> squares = new List<Rectangle>();
  public Form1() {
        InitializeComponent();
        
  }
    private void NonOptimizedSquares_Paint(object sender, PaintEventArgs e)
    {
      Pen pen = new Pen(Color.Red, 10);
      foreach (Rectangle square in squares) {
        e.Graphics.DrawRectangle(pen, square);
      }
      pen.Dispose();
      lblCount.Text = " " + squares.Count.ToString() + " squares"; 
    }
    private void NonOptimizedSquares_MouseDown(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButtons.Left)
      {
        Rectangle square = new Rectangle(e.X, e.Y, 20, 20);
        squares.Add(square);
                square.Inflate(1, 1);
                Invalidate(square);
      } 
    }
    private void InitializeComponent()
    {
      this.lblCount = new System.Windows.Forms.Label();
      this.SuspendLayout();
      // 
      // lblCount
      // 
      this.lblCount.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      this.lblCount.Dock = System.Windows.Forms.DockStyle.Bottom;
      this.lblCount.Location = new System.Drawing.Point(0, 251);
      this.lblCount.Name = "lblCount";
      this.lblCount.Padding = new System.Windows.Forms.Padding(2);
      this.lblCount.Size = new System.Drawing.Size(299, 21);
      this.lblCount.TabIndex = 0;
      // 
      // NonOptimizedSquares
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(299, 272);
      this.Controls.Add(this.lblCount);
      this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.Name = "NonOptimizedSquares";
      this.Text = "NonOptimizedSquares";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.NonOptimizedSquares_Paint);
      this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NonOptimizedSquares_MouseDown);
      this.ResumeLayout(false);
    }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


Use StatusBarPanel

 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class MenuHelpFirstTry: Form
{
     StatusBarPanel sbpMenuHelp;
     string         strSavePanelText;
   
     public static void Main()
     {
          Application.Run(new MenuHelpFirstTry());
     }
     public MenuHelpFirstTry()
     {
   
          StatusBar sb = new StatusBar();
          sb.Parent = this;
          sb.ShowPanels = true;
   
          sbpMenuHelp = new StatusBarPanel();
          sbpMenuHelp.Text = "Ready";
          sbpMenuHelp.AutoSize = StatusBarPanelAutoSize.Spring;
   
          sb.Panels.Add(sbpMenuHelp);
   
          Menu = new MainMenu();
          EventHandler ehSelect = new EventHandler(MenuOnSelect);
          
          MenuItem mi = new MenuItem("File");
          mi.Select += ehSelect;
          Menu.MenuItems.Add(mi);
   
          mi = new MenuItem("Open");
          mi.Select += ehSelect;
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItem("Close");
          mi.Select += ehSelect;
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItem("Save");
          mi.Select += ehSelect;
          Menu.MenuItems[0].MenuItems.Add(mi);
   
          mi = new MenuItem("Edit");
          mi.Select += ehSelect;
          Menu.MenuItems.Add(mi);
   
          mi = new MenuItem("Cut");
          mi.Select += ehSelect;
          Menu.MenuItems[1].MenuItems.Add(mi);
          
          mi = new MenuItem("Copy");
          mi.Select += ehSelect;
          Menu.MenuItems[1].MenuItems.Add(mi);
   
          mi = new MenuItem("Paste");
          mi.Select += ehSelect;
          Menu.MenuItems[1].MenuItems.Add(mi);
     }
     protected override void OnMenuStart(EventArgs ea)
     {
          strSavePanelText = sbpMenuHelp.Text;
     }
     protected override void OnMenuComplete(EventArgs ea)
     {
          sbpMenuHelp.Text = strSavePanelText;
     }
     void MenuOnSelect(object obj, EventArgs ea)
     {
          MenuItem mi = (MenuItem) obj;
          string   str;
   
          switch (mi.Text)
          {
              case "File":   str = "file";    break;
              case "Open":   str = "Open";         break;
              case "Close":  str = "Close";        break;
              case "Save":   str = "Save";         break;
              case "Edit":   str = "edit";  break;
              case "Cut":    str = "cut";         break;
              case "Copy":   str = "Copy";                          break;
              case "Paste":  str = "Paste";        break;
              default:       str = "";                                   break;
          }
   
          sbpMenuHelp.Text = str;
     }
}