Rediger

Del via


TreeNode.ToolTipText Property

Definition

Gets or sets the text that appears when the mouse pointer hovers over a TreeNode.

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

Property Value

Gets the text that appears when the mouse pointer hovers over a TreeNode.

Examples

The following code example demonstrates how to use the ToolTipText and ShowNodeToolTips properties. To run this example, paste the following code into a Windows Form and call InitializeTreeViewWithToolTips from the form's constructor or Load event handler.

TreeView treeViewWithToolTips;
private void InitializeTreeViewWithToolTips()
{
    treeViewWithToolTips = new TreeView();
    TreeNode node1 = new TreeNode("Node1");
    node1.ToolTipText = "Help for Node1";
    TreeNode node2 = new TreeNode("Node2");
    node2.ToolTipText = "A Tip for Node2";
    treeViewWithToolTips.Nodes.AddRange(new TreeNode[] { node1, node2 });
    treeViewWithToolTips.ShowNodeToolTips = true;
    this.Controls.Add(treeViewWithToolTips);
}
Private treeViewWithToolTips As TreeView

Private Sub InitializeTreeViewWithToolTips() 
    treeViewWithToolTips = New TreeView()
    Dim node1 As New TreeNode("Node1")
    node1.ToolTipText = "Help for Node1"
    Dim node2 As New TreeNode("Node2")
    node2.ToolTipText = "A Tip for Node2"
    treeViewWithToolTips.Nodes.AddRange(New TreeNode() {node1, node2})
    treeViewWithToolTips.ShowNodeToolTips = True
    Me.Controls.Add(treeViewWithToolTips)

End Sub

Remarks

You must set the ShowNodeToolTips property of the parent TreeView to true for the ToolTipText to be visible at run time.

If the TreeView control has a ToolTip and also contains a TreeNode that has a ToolTip, only the ToolTip for the node will be shown.

Applies to