ToolBarButton.ToolTipText Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the text that appears as a ToolTip for the button.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Property ToolTipText As String

Property Value

Type: System.String

The text that is displayed when the mouse pointer moves over the toolbar button. The default is an empty string ("").

To enable the display of the ToolTip text when the mouse pointer is moved over the button, set the ShowToolTips property of the button's parent ToolBar to true.

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. 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 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.

       ' 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.
   End Sub

.NET Framework
Available since 1.1
Return to top