I am trying to right align a control in a StatusStrip
. How can I do that?
I don't see a property to set on ToolStripItem
controls that specifies their physical alignment on the parent StatusStrip
.
I am trying to right align a control in a StatusStrip
. How can I do that?
I don't see a property to set on ToolStripItem
controls that specifies their physical alignment on the parent StatusStrip
.
You can display the
Button
at the end of theStatusStrip
by using the logic below.ToolstripLabel
to theStatusStrip
string.Empty
Padding
for theToolstripLabel
For example:
I find a general way to set a control's location in
StatusStrip
. You can display the Button at any position in theStatusStrip
by using the steps below.Set text as a suitable amount of space like
If layout is not what you want, got to step 2 to change the amount of space in
toolStripStatusLabel1.Text
, else work has been done.Found it via MSDN forums almost immediately after posting :)
You can use a
ToolStripLabel
to pseudo right align controls by setting theText
property tostring.Empty
and setting theSpring
property totrue
. This will cause it to fill all of the available space and push all the controls to the right of theToolStripLabel
over.Set the RightToLeft tool strip property to True.
For me it took two simple steps:
MyRightIntendedToolStripItem.Alignment
toRight
MyStatusStrip.LayoutStyle
toHorizontalStackWithOverflow
As an added note this is due to the fact that in the Win32 API a cell is either fixed width or fills the remaining space -1
If memory serves me correctly you can have only one fill cell (-1) per statusbar.
You could also add a third middle cell and give this the fill property to get a more concistent looking StatusBar. Consistent because Messages has an inset to its left right where you'd expect it. A bit like the mspaint shot found on the MSDN page for StatusBars
I like the creative appreach though :D