Adding tooltip to TreeView node

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dmitry Karneyev

    #1

    Adding tooltip to TreeView node

    Hi!
    How to add tooltip to a TreeView node?

    Thanks for any advice!

    Dmitry.


  • Adrian Mascarenhas

    #2
    RE: Adding tooltip to TreeView node


    [color=blue]
    >
    >Hi!
    >How to add tooltip to a TreeView node?
    >[/color]

    Here is one way that you could do:
    Fill out the tag property for the treenodes and on mousemove event, update
    the tooltip control with the tag property of the current node.



    private void Form1_Load(obje ct sender, System.EventArg s e)
    {
    TreeNode rootNode = this.treeView1. Nodes [0];
    rootNode.Tag="T his is the node 0";
    rootNode.Nodes[0].Tag="this is node 1";
    rootNode.Nodes[0].Nodes[0].Tag="this is node 2";

    }

    private void treeView1_Mouse Move(object sender,
    System.Windows. Forms.MouseEven tArgs e)
    {

    TreeNode currentNode = this.treeView1. GetNodeAt(e.X,e .Y);
    if (null != currentNode)
    {
    if (currentNode.Ta g.ToString() !=
    this.toolTip1.G etToolTip(this. treeView1).ToSt ring())
    {
    this.toolTip1.S etToolTip(this. treeView1,curre ntNode.Tag.ToSt ring());
    }
    }
    else
    {
    this.toolTip1.S etToolTip(this. treeView1,"");
    }
    }


    Hope this helps.
    --
    Adrian Mascarenhas, Developer Division

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Note: For the benefit of the community-at-large, all responses to this
    message are best directed to the newsgroup/thread from which they
    originated.

    Comment

    Working...