Solve the problem that the items on the statusStrip control cannot be right aligned.
The status bar control StatusStrip is used in c #, but an error occurs when I want to align a StatusLabel on StatusStrip to the right.
In MSDN, set the Alignment attribute of ToolStripStatusLabel to Right. However, I cannot find Alignment in the design attribute window.
Even if you add toolStripStatusLabel2.Alignment = ToolStripItemAlignment. Right;, it still has no effect.
Then I found two ways to solve this problem:
Method 1:
Add a blank StatusLabel before all items in the status bar (StatusLabel, ProgressBar, DropDownButton, etc.) and set its Spring attribute to True.
The Spring attribute is used to set whether the item fills up the remaining space. After it is set to True, all the items after the program is run will be squeezed to the Right to align to the right.
If you need to move a part of the items to the left and a part to the right, insert a blank StatusLabel in the middle of the two parts and set its Spring attribute to True.
This method is relatively simple and you do not need to manually add code. First Choice!
Method 2:
I accidentally discovered this method.
Set the LayoutStyle attribute of the StatusStrip control to HorizontalStackWithOverflow or StackWithOverflow.
Then, in the Code, modify the Alignment of an item on the status bar to "Right". This time, the result is "Right.
Example: this. toolStripStatusLabel1.Alignment = ToolStripItemAlignment. Right;
Note that if there are multiple items, the items are arranged from left to right in the left alignment and from right to left in the right alignment.
The problem is solved basically, but I still don't know why the ToolStripStatusLabel does not have the Alignment attribute in the attribute window. From the posts collected on the internet, it seems that no one else has this problem?
If anyone knows, let me know. By the way, I use VS2005 8.0.50727.42.
C # How do I achieve this by using the label on the statusStrip1 control?
Put a statusstrip control at the bottom of the MDI control, and add multiple statuslabels on the statusstrip control (click the arrow on the right of the statusstrip control and then click Edit items ), set borderstyle of all statuslabel to sunken, bordersides to all, and the last spring to true. This should be done!
C # statusstrip Control
Yes. In the StatusStrip Items set, each Item has the Margin attribute. You can set the spacing between each Item and the top, bottom, and bottom of other Items to implement the functions you want.