By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

tool tip question

100+
P: 153
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:
Expand|Select|Wrap|Line Numbers
  1. // Create a root node.
  2. TreeNode rootNode = treeView1.Nodes.Add("Day of Week");
  3.  
  4. // Create a series of child nodes and then set the Tag property for each.
  5. for (int count = 0; count <= 6; count++)
  6. {
  7.    DayOfWeek day = (DayOfWeek)count;
  8.    TreeNode childNode = rootNode.Nodes.Add(day.ToString());
  9.    childNode.Tag = "This day is " + day.ToString() + ".";
  10. }
  11.  
  12. // Expand all of the TreeView nodes.
  13. rootNode.ExpandAll();
  14.  
Paste the following code into the TreeView MouseMove event:

Expand|Select|Wrap|Line Numbers
  1. // Get the node at the current mouse pointer location.
  2. TreeNode theNode =  this.treeView1.GetNodeAt(e.X, e.Y);
  3.  
  4. // Set a ToolTip only if the mouse pointer is actually paused on a node.
  5. if ((theNode != null))
  6. {
  7.    // Verify that the tag property is not "null".
  8.    if (theNode.Tag != null)
  9.    {
  10.       // Change the ToolTip only if the pointer moved to a new node.
  11.       if (theNode.Tag.ToString()!=this.toolTip1.GetToolTip(this.treeView1))
  12.       {
  13.          this.toolTip1.SetToolTip(this.treeView1, theNode.Tag.ToString());
  14.       }
  15.    }     
  16.    else
  17.    {
  18.       this.toolTip1.SetToolTip(this.treeView1, "");
  19.    }
  20. }
  21. else     // Pointer is not over a node so clear the ToolTip.
  22. {
  23.    this.toolTip1.SetToolTip(this.treeView1, "");
  24. }
  25.  
  26.  
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.
Jan 8 '09 #1
Share this Question
Share on Google+
2 Replies


shweta123
Expert 100+
P: 692

100+
P: 153
Ty Shweta!
I had already read that discussion and made my program accordingly. :)
Jan 9 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.