步驟:
1.創建窗體及添加StatusStrip
默認StatusStrip名稱為statusStrip1
2.在statusStrip1的Items屬性中
添加三個StatusLabel
默認名稱為toolStripStatusLabel1,2,3
按1,2,3的順序排列
3.修改toolStripStatusLabel1的Text屬性
為相關文字如歡迎使用本系統
4.修改toolStripStatusLabel2的Text屬性 為空
Sprint屬性為True
BorderSides屬性為Left,Right
5.修改toolStripStatusLabel3的Text屬性 為空
在Form的Load事件中 修改其顯示為當前時間
[csharp] view plain copy
this.toolStripStatusLabel3.Text = 登錄時間: + DateTime.Now.ToString(yyyy-MM-dd hh:mm:ss);
6.如果要使狀態欄時間信息隨操作系統當前時間不停的改變
則可以通過增加Timer控件來實現
增加Timer控件 timer1
編寫其Tick事件為
[csharp] view plain copy
private void timer1_Tick(object sender, EventArgs e)
{
this.toolStripStatusLabel3.Text = 系統當前時間: + DateTime.Now.ToString(yyyy-MM-dd hh:mm:ss);
}
在Form的Load事件中 對timer1進行相關設置:
[csharp] view plain copy
private void MainForm_Load(object sender, EventArgs e)
{
this.toolStripStatusLabel3.Text = 系統當前時間: + DateTime.Now.ToString(yyyy-MM-dd hh:mm:ss);
this.timer1.Interval=1000;
this.timer1.Start();
}
