Any suggestions? Export (0) Print
Expand All

ToolStripItem.Overflow Property

 

Gets or sets whether the item is attached to the ToolStrip or ToolStripOverflowButton or can float between the two.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ToolStripItemOverflow Overflow { get; set; }

Property Value

Type: System.Windows.Forms.ToolStripItemOverflow

One of the ToolStripItemOverflow values. The default is AsNeeded.

Exception Condition
InvalidEnumArgumentException

The value assigned is not one of the ToolStripItemOverflow values.

Use the Overflow property in stack layouts. In flow and table layouts, the ToolStrip overflow button is not rendered, and therefore the Overflow property is ignored.

The following code example demonstrates how to set the Text, Overflow, and TextDirection properties, and handle the Click event. To run this example, paste the following code into a form that contains a ToolStrip named movingToolStrip and call InitializeMovingToolStrip in the form's constructor or Load event handler.

internal ToolStripButton changeDirectionButton;

private void InitializeMovingToolStrip()
{
          movingToolStrip = new ToolStrip();

	changeDirectionButton = new ToolStripButton();

	movingToolStrip.AutoSize = true;
	movingToolStrip.RenderMode = ToolStripRenderMode.System;

	changeDirectionButton.TextDirection = ToolStripTextDirection.Vertical270;
	changeDirectionButton.Overflow = ToolStripItemOverflow.Never;
	changeDirectionButton.Text = "Change Alignment";
		movingToolStrip.Items.Add(changeDirectionButton);
}


private void changeDirectionButton_Click(object sender, EventArgs e)
{

	ToolStripItem item = (ToolStripItem)sender;

	if (item.TextDirection == ToolStripTextDirection.Vertical270 || item.TextDirection == ToolStripTextDirection.Vertical90)
	{
		item.TextDirection = ToolStripTextDirection.Horizontal;
		movingToolStrip.Dock = System.Windows.Forms.DockStyle.Top;
	}
	else
	{
		item.TextDirection = ToolStripTextDirection.Vertical270;
		movingToolStrip.Dock = System.Windows.Forms.DockStyle.Left;
	}

}

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft