1: Add a status bar on the WinForm and add a few more labels to the status column.
Step1: Drag a StatusStrip to WinForm, the default name is STATUSSTRIP1. Locate the StatusStrip1 Items property, and double-click Open to add 3 Statuslabel. The default names are ToolStripStatusLabel1, ToolStripStatusLabel2, ToolStripStatusLabel3, respectively. They are displayed from left to right, respectively. Set the properties of the ToolStripStatusLabel2 to the left and right (that is, to display the border on both sides, which means to separate the labels on each side). and set the Spring property of ToolStripStatusLabel2 to True, meaning fill the status bar. Mouse over this spring place will show the meaning of the property.
Step2: The above step has completed the function of displaying the status bar on WinForm, and the status bar has 3 labels. (in depth, in the WinForm Status column to display the text, is to add StatusStrip first.) This is the container of the Status column information, to add the corresponding component if you want to display something on it. This is my understanding Ah, the specific display of words on the StatusStrip to add Statuslabel, then this label can display text. And the middle label has about 2 borders, the label is expanded, the overall look is covered with the entire status bar.
Step3. If you want to display the time on the Middle label, add a timer, this is a timer, drag from the left, and then the default name is Timer1, on the timer1 tick event, write the following code:
Private void Timer1_Tick (object sender, EventArgs e) { this" Current system time:" + DateTime.Now.ToString ("yyyy-mm-dd hh:mm:ss");
The tick response event is called when the timer's interval expires.
Write the following code in the OnLoad event of the form:
This " Current system time: " + DateTime.Now.ToString ("yyyy-mm-dd hh:mm:ss"); This + ; this. timer1. Start ();
Just fine, that is, the event is now displayed on the Label2, then starts the timer, sets the timer's interval (timed event), and then starts the Timer,tick event that is called when the interval expires.
It's finished!
Status bar in WinForm, and display time on Status column