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:
Preview:
Display Current Date and Time:
Preview:
I hope you like it. Thanks.
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();
}
}
}
|
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();
}
}
}
|
I hope you like it. Thanks.
[Download Source Code via Google Drive]
I love this site: good design and good content
ReplyDeleteThanks! Doan Phan Thai for your valuable comment.
DeleteThe site is very helpful
ReplyDeleteI love This site too. It very easy look and easy understand for all poeple. Thank You!
ReplyDeletethis is the type of site have been searching for, Good work Sharma
ReplyDelete