TreeNode.ToolTipText Property

Definition

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

C#
public string ToolTipText { get; set; }

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.

C#
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);
}

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

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9