ToolStripItem.TextDirection プロパティ

定義

ToolStripItem で使用されるテキストの方向を取得します。

public:
 virtual property System::Windows::Forms::ToolStripTextDirection TextDirection { System::Windows::Forms::ToolStripTextDirection get(); void set(System::Windows::Forms::ToolStripTextDirection value); };
public virtual System.Windows.Forms.ToolStripTextDirection TextDirection { get; set; }
member this.TextDirection : System.Windows.Forms.ToolStripTextDirection with get, set
Public Overridable Property TextDirection As ToolStripTextDirection

プロパティ値

ToolStripTextDirection 値のいずれか 1 つ。

次のコード例では、、AutoSize、、および の各プロパティをText設定しTextDirection、イベントを処理する方法をClickOverflowします。 この例を実行するには、次のコードを、フォームのコンストラクターまたはLoadイベント ハンドラーの 名前付き movingToolStrip および 呼び出InitializeMovingToolStripしを含むToolStripフォームに貼り付けます。

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

適用対象