You access the LayoutSettings object offered at the ToolStripLevel
and cast to the appropriate type and access the properties there. The following
is an example of changing the flow direction of a ToolStrip.
toolStrip1.LayoutStyle = ToolStripLayoutStyle.Flow;
((FlowLayoutSettings)toolStrip1.LayoutSettings).FlowDirection = FlowDirection.BottomUp;
How can I do dynamic text rotation as my ToolStrip changes orientation?
Sync the LayoutStyleChanged event on the ToolStrip. This
sample rotates the text to Vertical90 on vertical layouts. For best results,
start with a ToolStrip with standard items and make sure all ToolStripButton
display styles are set to ImageAndText.
private void toolStrip1_LayoutStyleChanged(object sender, EventArgs e)
{
if (toolStrip1.LayoutStyle == ToolStripLayoutStyle.VerticalStackWithOverflow)
{
toolStrip1.TextDirection = ToolStripTextDirection.Vertical90;
foreach (ToolStripItem tsi in toolStrip1.Items)
{
if (tsi is ToolStripButton)
{
tsi.TextImageRelation = TextImageRelation.ImageAboveText;
}
}
}
else
{
toolStrip1.TextDirection = ToolStripTextDirection.Horizontal;
foreach (ToolStripItem tsi in toolStrip1.Items)
{
if (tsi is ToolStripButton)
{
tsi.TextImageRelation = TextImageRelation.ImageBeforeText;
}
}
}
}
Dock
ToolStrips have three main usage patterns. One of those is docking
within a parent container. ToolStrips follow the same rules as other Windows Forms
controls with regards to docking, except when Joined into a ToolStripPanel. See
ToolStripPanel for additional information.