Effect:
Display the status bar of the form through statusstrip
At the same time, the status bar is divided into three parts
Display text information on the left
Blank in the middle
Display time information on the right side
Statusstrip sb = new statusstrip ();
Toolstriplabel TSL = new toolstriplabel (); // defines controls in the statusstrip project, where toolstriplabel is a label-like control and is now used to display text
TSL. Text = "test"; // text to be displayed
Toolstripitem [] TSI = new toolstripitem [1]; // defines a project in statusstrip
Tsi [0] = TSL;
SB. Items. addrange (TSI); // Add the project to statusstrip
This. Controls. Add (sb); // Add StatusStrip to the form
1. Create a form and add StatusStrip
The default StatusStrip name is statusStrip1.
2. In the Items attribute of statusStrip1
Add three statuslabels
Default names: toolStripStatusLabel1, 2, 3
Sort by 1, 2, 3
3. Modify the Text attribute of toolStripStatusLabel1
For related text, such as "welcome to use this system"
4. Modify the Text attribute of toolStripStatusLabel2 to null.
The Sprint attribute is True.
The BorderSides attribute is Left and Right.
5. Modify the Text attribute of toolStripStatusLabel3 to null.
In the Form Load event, modify the display time to the current time.
This. toolStripStatusLabel3.Text = "Logon Time:" + DateTime. Now. ToString ("yyyy-MM-dd hh: mm: ss ");
6. If you want to keep the status bar time information changing with the current operating system time
You can add the Timer control to implement
Added Timer control timer1
Compile the Tick event
P rivate void timereffectick (object sender, EventArgs e)
{
This. toolStripStatusLabel3.Text = "current system time:" + DateTime. Now. ToString ("yyyy-MM-dd hh: mm: ss ");
}
Set timer1 in the Form Load event
P rivate void MainForm_Load (object sender, EventArgs e)
{
This. toolStripStatusLabel3.Text = "current system time:" + DateTime. Now. ToString ("yyyy-MM-dd hh: mm: ss ");
This. timer1.Interval = 1000;
This. timer1.Start ();
}