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