The position of the ToolStripStatusLabel in the StatusStrip control

Source: Internet
Author: User

The status bar control StatusStrip was used in C #, but there was a problem when I tried to align one of the Statuslabel on the StatusStrip to the right.

As you can do in MSDN, set the Alignment property of ToolStripStatusLabel to right. But I can't find alignment in the Properties window of the design interface.

Even if you add code toolstripstatuslabel2.alignment = toolstripitemalignment.right; There is still no effect.

Then I found two ways to solve the problem:

Method One:

Add a blank Statuslabel (the Text property is empty) before all items in the status bar (Statuslabel, ProgressBar, DropDownButton, and so on), and set its Spring property to true.

The function of the spring property is to set whether the item fills the remaining space, and when it is set to true, the items that follow when the program is run are pushed to the right, and the implementation is aligned to the right.

If you go further, you need some of the items on the left and some on the right, then insert a blank statuslabel between the two parts and set their spring property to true.

This method is relatively simple and does not have to be manually added code. Preferred!

Method Two:

This method was discovered by me unintentionally.

Sets the Layoutstyle property of the StatusStrip control to Horizontalstackwithoverflow or Stackwithoverflow.

Then, in the code, modify the alignment of an item on the status bar to right, and this time it will have an effect on the left.

For example: this.toolStripStatusLabel1.Alignment = toolstripitemalignment.right;

Note: If there are multiple items, align left-aligned left-to-right, right-aligned from right to left.

It has been found in practice that the first method is particularly reliable

The second method cannot be found in the property box and must be written in code when the form is loaded;


The position of the ToolStripStatusLabel in the StatusStrip control

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.