ToolBarButton.Text ToolBarButton.Text ToolBarButton.Text ToolBarButton.Text Property

Definición

Obtiene o establece el texto mostrado en el botón de barra de herramientas.Gets or sets the text displayed on the toolbar button.

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

Valor de propiedad

Texto mostrado en el botón de barra de herramientas.The text displayed on the toolbar button. El valor predeterminado es una cadena vacía ("").The default is an empty string ("").

Ejemplos

En el ejemplo de código siguiente ToolBar se crea ToolBarButton un control y tres controles, se asignan los botones a la barra de herramientas y se establecen algunas de las propiedades comunes de los botones.The following code example creates a ToolBar and three ToolBarButton controls, assigns the buttons to the toolbar, and sets some of the buttons' common properties. Este código MenuItemrequiere que se haya creado ToolTip , ImageListy Form un y ImageList que tenga al menos un Image asignado.This code requires that a MenuItem, ImageList, ToolTip and a Form have been created and the ImageList has at least one Image assigned to it.

public:
   void InitializeMyToolBar()
   {
      // Create the ToolBar, ToolBarButton controls, and menus.
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton( "Open" );
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      ToolBar^ toolBar1 = gcnew ToolBar;
      MenuItem^ menuItem1 = gcnew MenuItem( "Print" );
      array<MenuItem^>^ temp1 = {menuItem1};
      System::Windows::Forms::ContextMenu^ contextMenu1 =
         gcnew System::Windows::Forms::ContextMenu( temp1 );
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Assign an ImageList to the ToolBar and show ToolTips.
      toolBar1->ImageList = imageList1;
      toolBar1->ShowToolTips = true;
      
      /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
         Style properties of the ToolBarButton controls. */
      toolBarButton2->Style = ToolBarButtonStyle::Separator;
      toolBarButton3->Text = "Print";
      toolBarButton3->Style = ToolBarButtonStyle::DropDownButton;
      toolBarButton3->ToolTipText = "Print";
      toolBarButton3->ImageIndex = 0;
      toolBarButton3->DropDownMenu = contextMenu1;
      
      // Add the ToolBar to a form.
      Controls->Add( toolBar1 );
   }
public void InitializeMyToolBar()
 {
    // Create the ToolBar, ToolBarButton controls, and menus.
    ToolBarButton toolBarButton1 = new ToolBarButton("Open");
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
    ToolBar toolBar1 = new ToolBar();
    MenuItem menuItem1 = new MenuItem("Print");
    ContextMenu contextMenu1 = new ContextMenu(new MenuItem[]{menuItem1});

     
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
 
    // Assign an ImageList to the ToolBar and show ToolTips.
    toolBar1.ImageList = imageList1;
    toolBar1.ShowToolTips = true;
 
    /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
       Style properties of the ToolBarButton controls. */
    toolBarButton2.Style = ToolBarButtonStyle.Separator;
    toolBarButton3.Text = "Print";
    toolBarButton3.Style = ToolBarButtonStyle.DropDownButton;
    toolBarButton3.ToolTipText = "Print";
    toolBarButton3.ImageIndex = 0;
    toolBarButton3.DropDownMenu = contextMenu1;
 
    // Add the ToolBar to a form.
    Controls.Add(toolBar1);
 }
 
   Public Sub InitializeMyToolBar()
       ' Create the ToolBar, ToolBarButton controls, and menus.
       Dim toolBarButton1 As New ToolBarButton("Open")
       Dim toolBarButton2 As New ToolBarButton()
       Dim toolBarButton3 As New ToolBarButton()
       Dim toolBar1 As New ToolBar()
Dim menuItem1 As New MenuItem("Print")
Dim contextMenu1 As New ContextMenu(New MenuItem(){menuItem1})
       
       ' Add the ToolBarButton controls to the ToolBar.
       toolBar1.Buttons.Add(toolBarButton1)
       toolBar1.Buttons.Add(toolBarButton2)
       toolBar1.Buttons.Add(toolBarButton3)
       
       ' Assign an ImageList to the ToolBar and show ToolTips.
       toolBar1.ImageList = imageList1
       toolBar1.ShowToolTips = True
       
       ' Assign ImageIndex, ContextMenu, Text, ToolTip, and
       ' Style properties of the ToolBarButton controls. 
       toolBarButton2.Style = ToolBarButtonStyle.Separator
       toolBarButton3.Text = "Print"
       toolBarButton3.Style = ToolBarButtonStyle.DropDownButton
       toolBarButton3.ToolTipText = "Print"
       toolBarButton3.ImageIndex = 0
       toolBarButton3.DropDownMenu = contextMenu1
       
       ' Add the ToolBar to a form.
       Controls.Add(toolBar1)
   End Sub

Comentarios

El valor predeterminado de la propiedad Text es una cadena vacía ("") a menos que se haya creado ToolBar el control con el constructor que acepta la cadena de texto como un parámetro.The default the Text property value is an empty string ("") unless you created the control with the ToolBar constructor that accepts the text string as a parameter. La orientación del texto en el botón de la barra de herramientas viene TextAlign determinada por la propiedad del elemento ToolBarprimario del botón, que se puede establecer en ToolBarTextAlign uno de los valores de enumeración.The orientation of the text on the toolbar button is determined by the TextAlign property of the button's parent ToolBar, which can be set to one of the ToolBarTextAlign enumeration values. La orientación es relacionada con la imagen asignada al botón.The orientation is in relation to the image assigned to the button. Si no hay ninguna imagen asignada al botón, habrá espacio restante para una en la superficie del botón de la barra de herramientas.If no image is assigned to the button, there will be space left for one on the surface of the toolbar button.

Se aplica a

Consulte también: