Client Position for RadTreeNode

5 posts, 1 answers
  1. AccSys
    AccSys avatar
    9 posts
    Member since:
    May 2011

    Posted 24 Jun 2011 Link to this post

    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
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 29 Jun 2011 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. AccSys
    AccSys avatar
    9 posts
    Member since:
    May 2011

    Posted 29 Jun 2011 Link to this post

    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
  5. Answer
    Jack
    Admin
    Jack avatar
    2335 posts

    Posted 04 Jul 2011 Link to this post

    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!
  6. AccSys
    AccSys avatar
    9 posts
    Member since:
    May 2011

    Posted 04 Jul 2011 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready