ToolStripItem.AutoSize ToolStripItem.AutoSize ToolStripItem.AutoSize ToolStripItem.AutoSize Property

정의

항목의 크기가 자동으로 조정되는지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the item is automatically sized.

public:
 property bool AutoSize { bool get(); void set(bool value); };
public bool AutoSize { get; set; }
member this.AutoSize : bool with get, set
Public Property AutoSize As Boolean

속성 값

ToolStripItem의 크기를 자동으로 조정하면 true이고, 그렇지 않으면 false입니다.true if the ToolStripItem is automatically sized; otherwise, false. 기본값은 true입니다.The default value is true.

예제

다음 코드 예제에서는 설정 하는 방법에 설명 합니다 Text, AutoSize, Overflow, 및 TextDirection 속성 및 핸들은 Click 이벤트.The following code example demonstrates how to set the Text, AutoSize, Overflow, and TextDirection properties, and handle the Click event. 이 예제를 실행 하려면 다음 코드를 포함 하는 형식으로 붙여넣습니다를 ToolStrip 라는 movingToolStrip 호출 InitializeMovingToolStrip 폼의 생성자에서 또는 Load 이벤트 처리기입니다.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;
    }
}


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;
    }

}
Friend WithEvents changeDirectionButton As ToolStripButton

Private Sub InitializeMovingToolStrip()
    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)
End Sub


Public Sub changeDirectionButton_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles changeDirectionButton.Click

    Dim item As ToolStripItem = CType(sender, ToolStripItem)

    If item.TextDirection = ToolStripTextDirection.Vertical270 _
        OrElse item.TextDirection = ToolStripTextDirection.Vertical90 Then

        item.TextDirection = ToolStripTextDirection.Horizontal
        movingToolStrip.Dock = System.Windows.Forms.DockStyle.Top
    Else
        item.TextDirection = ToolStripTextDirection.Vertical270
        movingToolStrip.Dock = System.Windows.Forms.DockStyle.Left
    End If

End Sub

설명

설정 합니다 AutoSize 속성을 true 시킬를 ToolStripItem 높이 또는 너비의 방향에 따라 조정 하는 ToolStrip을 보장 하기를 ToolStripItem 필요한 만큼의 공간을 사용 하 여 합니다.Set the AutoSize property to true to cause the ToolStripItem to adjust either its height or width, depending on the orientation of the ToolStrip, to ensure that the ToolStripItem uses only the required amount of space.

A ToolStripItem 의 경우 크기는 최소 합니다 AutoSize 속성은 true합니다.A ToolStripItem has a minimum size if the AutoSize property is true. 설정 합니다 AutoSize 속성을 false 하려는 경우를 ToolStripItem 시스템에 정의 된 최소 크기 보다 더 작게 할 또는 ToolStripItem 크기를 0입니다.Set the AutoSize property to false if you want a ToolStripItem to be smaller than the system-defined minimum size or to have a ToolStripItem size of zero.

적용 대상