Display message in StatusBar : StatusBar « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » StatusBarScreenshots 
Display message in StatusBar


using System;
using System.Collections.Generic;
using System.ComponentModel;
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.ComboBox 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, 1050);
            statusBar.Items[0].Text = lstFonts.Text;
    }
  }

  private void InitializeComponent()
  {
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.lstFonts = new System.Windows.Forms.ComboBox();
    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(70);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(49740);
    this.groupBox1.TabIndex = 1;
    this.groupBox1.TabStop = false;
    // 
    // lstFonts
    // 
    this.lstFonts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    this.lstFonts.DropDownWidth = 340;
    this.lstFonts.FormattingEnabled = true;
    this.lstFonts.Location = new System.Drawing.Point(10012);
    this.lstFonts.Name = "lstFonts";
    this.lstFonts.Size = new System.Drawing.Size(34021);
    this.lstFonts.TabIndex = 1;
    this.lstFonts.SelectedIndexChanged += new System.EventHandler(this.lstFonts_SelectedIndexChanged);
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(1216);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(8012);
    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(0155);
    this.statusBar.Name = "statusBar";
    this.statusBar.Size = new System.Drawing.Size(51622);
    this.statusBar.TabIndex = 2;
    this.statusBar.Text = "statusStrip1";
    // 
    // statusLabel
    // 
    this.statusLabel.Name = "statusLabel";
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(516177);
    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());
  }

}


           
       
Related examples in the same category
1.Use Label as status barUse Label as status bar
2.Add icon to statusbarAdd icon to statusbar
3.Display current time on statusbarDisplay current time on statusbar
4.Display menu item alert message on the statusbarDisplay menu item alert message on the statusbar
5.StatusBar with two panelsStatusBar with two panels
6.Status bar: display time and prompt message for menu itemStatus bar: display time and prompt message for menu item
7.StatusBar ExampleStatusBar Example
8.Status Strip Example
9.Use StatusBarPanel
10.Add StatusPanels to StatusBar
11.Set Text to Statusbar
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.