Use Label as status bar : 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 
Use Label as status bar
Use Label as status bar


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.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, 2020);
        squares.Add(square);
                square.Inflate(11);
                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(0251);
      this.lblCount.Name = "lblCount";
      this.lblCount.Padding = new System.Windows.Forms.Padding(2);
      this.lblCount.Size = new System.Drawing.Size(29921);
      this.lblCount.TabIndex = 0;
      // 
      // NonOptimizedSquares
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(299272);
      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());
  }

}


           
       
Related examples in the same category
1.Display message in StatusBar
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.