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:
property ToolStripItemOverflow Overflow {
	ToolStripItemOverflow get();
	void set(ToolStripItemOverflow value);
}

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.

ToolStripButton^ changeDirectionButton;

void InitializeMovingToolStrip()
{
    changeDirectionButton = gcnew ToolStripButton;
    movingToolStrip->AutoSize = true;
    movingToolStrip->RenderMode = ToolStripRenderMode::System;
    changeDirectionButton->TextDirection = 
        ToolStripTextDirection::Vertical270;
    changeDirectionButton->Overflow = 
        ToolStripItemOverflow::Never;
    changeDirectionButton->Text = "Change Alignment";
    movingToolStrip->Items->Add(changeDirectionButton);
    changeDirectionButton->Click += gcnew EventHandler(this, 
        &Form1::changeDirectionButtonClick);
}

void changeDirectionButtonClick(Object^ sender, EventArgs^ e)
{
    ToolStripItem^ item = (ToolStripItem^) sender;
    if ((item->TextDirection == ToolStripTextDirection::Vertical270) 
        || (item->TextDirection == ToolStripTextDirection::Vertical90))
    {
        item->TextDirection = ToolStripTextDirection::Horizontal;
        movingToolStrip->Raft = RaftingSides::Top;
    }
    else
    {
        item->TextDirection = 
            ToolStripTextDirection::Vertical270;
        movingToolStrip->Raft = RaftingSides::Left;
    }
}


.NET Framework
Available since 2.0
Return to top
Show: