dotnetmonitor.com

 
Index
Previous
Next

 

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 ToolStripPanelfor additional information.

Painting
When should I use Paint/OnPaint and when should I override the ToolStripRenderer?
Do I need to worry about double buffering?
Parenting
Partial Trust
Usage