ToolStripItem.Text 속성

정의

항목에 표시되는 텍스트를 가져오거나 설정합니다.Gets or sets the text that is to be displayed on the item.

public:
 virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public virtual string Text { get; set; }
member this.Text : string with get, set
Public Overridable Property Text As String

속성 값

항목의 텍스트를 나타내는 문자열입니다.A string representing the item's text. 기본값은 빈 문자열("")입니다.The default value is the empty string ("").

예제

다음 코드 예제에서는 설정 하는 방법에 설명 합니다 Text, Overflow, 및 TextDirection 속성 및 처리를 Click 이벤트.The following code example demonstrates how to set the Text, 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

설명

앰퍼샌드를 추가 하 여 ("&") 텍스트 값의 문자를 항목에 액세스 키를 만들 수 있습니다.You can create an access key to the item by adding an ampersand ("&") before a letter in the text value. 자세한 내용은 방법: Windows Forms 컨트롤에 대 한 선택 키를 만듭니다.For more information, see How to: Create Access Keys for Windows Forms Controls.

ToolStripItem 사용 하는 Text 속성에 대 한 기본 원본으로는 ToolTip 콘텐츠입니다.ToolStripItem uses the Text property as the default source for the ToolTip content. 설정 AutoToolTipfalse 사용 하려면 ToolTipText 원본으로 ToolTip 콘텐츠입니다.Set AutoToolTip to false to use ToolTipText as the source for ToolTip content.

적용 대상