This is a migrated thread and some comments may be shown as answers.

Client Position for RadTreeNode

4 Answers 213 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
AccSys
Top achievements
Rank 1
AccSys asked on 24 Jun 2011, 04:16 PM
Hi, 

Is there a way to get either the bounds or the client x,y position of a RadTreeNode item so I can point a Tooltip at a tree item?  Either that or be able to get the window handle for the tree item so I can use that in the tooltip.Show() method.

Thanks
Paul

4 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 29 Jun 2011, 11:13 AM
Hi AccSys,

Thank you for this question. 

In general, you do not have to handle an event and check node coordinates to show a node tooltip in RadTreeView. All you have to do is to set the  ShowNodeToolTips property to true (which is by default) and then set the desired tooltip text for every node:
view.Nodes[0].Nodes[0].ToolTipText = "wewer";
view.ShowNodeToolTips = false;

Of course, if you want to handle this manually, you can get the node at given coordinates by using the GetNodeElementAt method:
void view_MouseMove(object sender, MouseEventArgs e)
{
    TreeNodeElement nodeElement = this.radTreeView1.TreeViewElement.GetNodeElementAt(e.Location);
    if (nodeElement != null)
    {
        //...
    }
}

I hope this helps. If you have any further questions, do not hesitate to ask.

Greetings,
Jack
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
AccSys
Top achievements
Rank 1
answered on 29 Jun 2011, 11:31 AM
Thanks for the response, but this isn't exactly what I want to do.  I need to be able to show a Balloon tooltip over a specific node in the treeview as a "Where is my item?" function.

We have various treeviews in numerous PageViews, and I need to "Show" the user where the item is they've selected in a completely unrelated view (in this case a Modal Dialog).

Can the tooltips be shown as Balloons?  I don't want the tooltip to appear when the mouse is over a node, otherwise I'd have done what you suggested :)

Paul
0
Accepted
Jack
Telerik team
answered on 04 Jul 2011, 10:04 AM
Hello Accsys,

Thank you for this clarification. You can show and position the balloon by using the ControlBoundingRectangle property of the desired TreeNodeElement. Please consider the following sample:
ToolTip tip = new ToolTip();
bool tipVisible;
 
private void radButton1_Click(object sender, EventArgs e)
{
    if (tipVisible)
    {
        return;
    }
 
    RadTreeNode node = this.radTreeView1.Nodes[0].Nodes[2];
    TreeNodeElement element = this.radTreeView1.TreeViewElement.GetElement(node);
    if (element != null)
    {
        Point location = element.ContentElement.ControlBoundingRectangle.Location;
        tip.IsBalloon = true;
        tip.SetToolTip(this.radTreeView1, "Caption");
        tip.Show("I am a tooltip", this.radTreeView1, location);
        tipVisible = true;
    }
}

In case you need further assistance, I will be glad to help.
 
Kind regards,
Jack
the Telerik team
Registration for Q2 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting July 18th and book your seat for a walk through all the exciting stuff we ship with the new release!
0
AccSys
Top achievements
Rank 1
answered on 04 Jul 2011, 10:58 AM
Thanks, that's sorted it.  As a side note for anyone else doing the same, make sure the toolTip.Show() method is called twice for a Balloon tooltip to show correctly.
Tags
Treeview
Asked by
AccSys
Top achievements
Rank 1
Answers by
Jack
Telerik team
AccSys
Top achievements
Rank 1
Share this question
or