StatusBarPanel.BorderStyle : StatusBarPanel « System.Windows.Forms « C# / C Sharp by API






StatusBarPanel.BorderStyle

 


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class FormWithStatusBar : 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.ComponentModel.Container components;

  public FormWithStatusBar()
  {
    InitializeComponent();

    timer1.Interval = 1000;
    timer1.Enabled = true;
    timer1.Tick += new EventHandler(timer1_Tick);
    this.MenuComplete += new EventHandler(StatusForm_MenuDone);
    BuildMenuSystem();
    BuildStatBar();
  }


  private void InitializeComponent()
  {
    this.components = new System.ComponentModel.Container();
    this.Size = new System.Drawing.Size(300,300);
    this.Text = "Form1";
  }
  [STAThread]
  static void Main() 
  {
    Application.Run(new FormWithStatusBar());
  }

  private void FileExit_Clicked(object sender, EventArgs e) 
  {    
    this.Close();
  }
    
  private void HelpAbout_Clicked(object sender, EventArgs e) 
  {
    sbPnlPrompt.Text = "Help";
  }
    
  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";
  }

  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()
  {
    statusBar.ShowPanels = true;
    statusBar.Panels.AddRange(new StatusBarPanel[] {sbPnlPrompt, sbPnlTime});
    
    sbPnlPrompt.BorderStyle = StatusBarPanelBorderStyle.None;
    sbPnlPrompt.AutoSize = StatusBarPanelAutoSize.Spring;
    sbPnlPrompt.Width = 62;
    sbPnlPrompt.Text = "Ready";
    
    sbPnlTime.Alignment = HorizontalAlignment.Right;
    sbPnlTime.Width = 76;

    this.Controls.Add(statusBar);  
  }
}

   
  








Related examples in the same category

1.StatusBarPanel.Icon
2.StatusBarPanel.Text
3.StatusBarPanel.ToolTipText