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

プロパティ値

true 場合、ToolStripItem自動的にサイズは、それ以外の場合は、falseします。true if the ToolStripItem is automatically sized; otherwise, false. 既定値は true です。The default value is true.

次のコード例は、設定する方法を示します、 TextAutoSizeOverflow、および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.

AToolStripItem場合は、最小サイズを持つ、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.

適用対象