Support us on YouTube by Subscribing our YouTube Channel. Click here to Subscribe our YouTube Channel

Saturday 7 March 2015

Display Date and Time in StatusStrip / StatusBar in Windows Form Application

Generally, You have seen many applications in which Date and Time is displayed in the StatusBar. In this Article, We will see How to Display Date and Time in StatusStrip / StatusBar in Windows Form Application.

Let's Begin:
1. Open Visual Studio and Create a New Windows Form Application.
2. Drop StatusStrip Control from the ToolBox.
3. Click on down arrow of StatusStrip and add StatusLabel on it (named as toolStripStatusLabel1).
Set Text of toolStripStatusLabel1 as Empty or "".
4. Drop the Timer control from the ToolBox -> Go to Properties of timer1 control -> Set Interval to 1000 milliseconds and Enabled to True.
5. Create Tick event of timer1 control by double clicking on the timer1 control and Add following line of code:
using System;
using System.Windows.Forms;

namespace StatusBarDateTime
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //Timer Tick Event
        private void timer1_Tick(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = DateTime.Today.ToLongDateString();
        }
    }
}
Preview:

Display Current Date and Time:
using System;
using System.Windows.Forms;

namespace StatusBarDateTime
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //Timer Tick Event
        private void timer1_Tick(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = DateTime.Now.ToString();
        }
    }
}
Preview:
I hope you like it. Thanks.
[Download Source Code via Google Drive]

5 comments:

  1. I love this site: good design and good content

    ReplyDelete
    Replies
    1. Thanks! Doan Phan Thai for your valuable comment.

      Delete
  2. I love This site too. It very easy look and easy understand for all poeple. Thank You!

    ReplyDelete
  3. this is the type of site have been searching for, Good work Sharma

    ReplyDelete

Subscribe us on YouTube

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Like us on Facebook