tool tip question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akshaycjoshi
    New Member
    • Jan 2007
    • 153

    #1

    tool tip question

    I have got one treeview contol in which i create nodes dynamically.
    I want to set a tool tip for each of the node created.
    I went throught this tutorial

    How to add a ToolTip to a TreeNode in Visual C#

    Code in this tutorial is as


    Add the ToolTip to the TreeNodes

    Paste the following code into the Form1 Load event:
    Code:
    // Create a root node.
    TreeNode rootNode = treeView1.Nodes.Add("Day of Week");
    
    // Create a series of child nodes and then set the Tag property for each.
    for (int count = 0; count <= 6; count++)
    {
       DayOfWeek day = (DayOfWeek)count;
       TreeNode childNode = rootNode.Nodes.Add(day.ToString());
       childNode.Tag = "This day is " + day.ToString() + ".";
    }
    
    // Expand all of the TreeView nodes.
    rootNode.ExpandAll();
    Paste the following code into the TreeView MouseMove event:

    Code:
    // Get the node at the current mouse pointer location.
    TreeNode theNode =  this.treeView1.GetNodeAt(e.X, e.Y);
    
    // Set a ToolTip only if the mouse pointer is actually paused on a node.
    if ((theNode != null))
    {
       // Verify that the tag property is not "null".
       if (theNode.Tag != null)
       {
          // Change the ToolTip only if the pointer moved to a new node.
          if (theNode.Tag.ToString()!=this.toolTip1.GetToolTip(this.treeView1))
          {
             this.toolTip1.SetToolTip(this.treeView1, theNode.Tag.ToString());
          }
       }     
       else
       {
          this.toolTip1.SetToolTip(this.treeView1, "");
       }
    }
    else     // Pointer is not over a node so clear the ToolTip.
    {
       this.toolTip1.SetToolTip(this.treeView1, "");
    }
    When i apply this to my dynamically created nodes, This is happeneing



    (1)I want the tooltip to wait for sometime before showing the tooptip when the mouse is on the node.
    (2)he tooltip should be shown only when the mouse is over the text of the node(not on the node)
    (3)The top left corner of tooltip should be on the mouse pointer so that people can see the node test when the tooltiop is being shown.
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Please refer this thread :
    How to change ToolTip's position on a TreeView? - Stack Overflow

    Comment

    • akshaycjoshi
      New Member
      • Jan 2007
      • 153

      #3
      Ty Shweta!
      I had already read that discussion and made my program accordingly. :)

      Comment

      Working...