Status bar in WinForm, and display time on Status column

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.