How to align controls in StatusStrip?

I am trying to align a control in a StatusStrip . How can i do this?

I do not see the property to set on ToolStripItem elements that determine their physical alignment on the parent StatusStrip .

How to get drop-down messages for right alignment? http://i.friendfeed.com/ed90b205f64099687db30553daa79d075f280b90

+81
c # winforms statusstrip
Feb 03 '09 at 23:44
source share
6 answers

Found it through the MSDN forums almost immediately after posting :)

You can use ToolStripLabel for pseudo-right alignment by setting the Text property to string.Empty and setting the Spring property to true . This will make it fill all available space and click on all controls to the right of ToolStripLabel .

Right aligned posts http://i.friendfeed.com/f2fc7799d0897a4e835eedde83416f50c245cd6d

+192
Feb 03 '09 at 23:47
source share

As an added note, this is due to the fact that in the Win32 API the cell has either a fixed width or fills the remaining space -1

 int statwidths[] = {100, -1}; SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths); SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)"); 

If the memory is working correctly, you can only have one fill cell (-1) for each status bar.

You can also add a third middle cell and give this fill property to get a more consistent look of the StatusBar. Agreed, because the posts have an insert from left to right where you expect this. A bit like the mspaint snapshot found on the MSDN page for StatusBars

I like the creative approach: D

+4
Feb 04 '09 at 0:03
source share

You can display the Button at the end of the StatusStrip using the following logic.

  • Add ToolstripLabel to StatusStrip
  • Set text as string.Empty
  • Install Padding for ToolstripLabel

For example:

 this.toolStripStatusLabel1.Padding = new Padding((int)(this.Size.Width - 75), 0, 0, 0); 
+2
16 Sept. '14 at 13:22
source share

Save the Toolstrip label, set the Spring property to true, and to align label labels in BottomLeft

+1
Apr 18 '17 at 14:23
source share

Since the answer has been accepted, there is now a much simpler way. Just set the property of the RightToLeft tool to True.

-one
May 09 '16 at 17:50
source share

I find a general way to set the control location in StatusStrip . You can display the button at any position in the StatusStrip using the following steps.

  • Add ToolstripLabel to StatusStrip
  • Set the text as a suitable space, e.g.

    toolStripStatusLabel1.Text = "";

  • If the layout is not what you want, go to step 2 to change the amount of space in toolStripStatusLabel1.Text , otherwise the job was done.

-one
May 18 '17 at 7:30 a.m.
source share



All Articles