TreeView Question

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

    #1

    TreeView Question

    Hi,

    I want to display a 'hover box' (for want of a better description) when

    the mouse hovers over a node in a tree view. The box would display
    detail information for the node. It should be small, something like a
    tool tip.


    Does anyone have any idea of how to do this? I would really appreciate
    any assistance, especially a code snippet or two.


    Thanks!


    ~ Si

  • Kevin Spencer

    #2
    Re: TreeView Question

    Handle the NodeMouseHover event of the TreeView. It contains arguments that
    indicate which node is being hovered over. Then all you have to do is
    implement a ToolTip (or rool your own), and display it wherever you want to,
    in whatever way you want to.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    Professional Chicken Salad Alchemist

    Big thicks are made up of lots of little thins.


    "sianan" <smartin5321@td s.net> wrote in message
    news:1151201316 .872428.28930@u 72g2000cwu.goog legroups.com...[color=blue]
    > Hi,
    >
    > I want to display a 'hover box' (for want of a better description) when
    >
    > the mouse hovers over a node in a tree view. The box would display
    > detail information for the node. It should be small, something like a
    > tool tip.
    >
    >
    > Does anyone have any idea of how to do this? I would really appreciate
    > any assistance, especially a code snippet or two.
    >
    >
    > Thanks!
    >
    >
    > ~ Si
    >[/color]


    Comment

    • sianan

      #3
      Re: TreeView Question

      Thanks Kevin,

      I still can't make it work though. Not sure how I should implement the
      ToolTip and associate it with the selected node. Here's what I've got:

      private void myTreeView_Node MouseHover(obje ct sender,
      TreeNodeMouseHo verEventArgs e)
      {
      e.Node.ToolTipT ext = "descriptio n";

      }

      Something is obviously missing (just can't figure it out).

      Thanks!



      Kevin Spencer wrote:[color=blue]
      > Handle the NodeMouseHover event of the TreeView. It contains arguments that
      > indicate which node is being hovered over. Then all you have to do is
      > implement a ToolTip (or rool your own), and display it wherever you want to,
      > in whatever way you want to.
      >
      > --
      > HTH,
      >
      > Kevin Spencer
      > Microsoft MVP
      > Professional Chicken Salad Alchemist
      >
      > Big thicks are made up of lots of little thins.
      >
      >
      > "sianan" <smartin5321@td s.net> wrote in message
      > news:1151201316 .872428.28930@u 72g2000cwu.goog legroups.com...[color=green]
      > > Hi,
      > >
      > > I want to display a 'hover box' (for want of a better description) when
      > >
      > > the mouse hovers over a node in a tree view. The box would display
      > > detail information for the node. It should be small, something like a
      > > tool tip.
      > >
      > >
      > > Does anyone have any idea of how to do this? I would really appreciate
      > > any assistance, especially a code snippet or two.
      > >
      > >
      > > Thanks!
      > >
      > >
      > > ~ Si
      > >[/color][/color]

      Comment

      • Kevin Spencer

        #4
        Re: TreeView Question

        Hi sianan,

        If you set the TreeView's ShowNodeToolTip s property to true, you don't even
        have to handle the OnMouseOver event if you only want to display a ToolTip
        on a TreeNode when the mouse hovers over it. Just set the node's ToolTipText
        property. However, if you want to dynamically assign the ToolTipText when
        the Mouse hovers over the TreeNode, this will be much more difficult. The
        ToolTip will pop up before the event is fired, and the text assigned will be
        the text that was assigned prior to the event.

        Now, I haven't tested this, but I believe it would be possible to handle the
        TreeView.MouseM ove event to do this. The trick is getting the TreeNode that
        the mouse is over. This is done using the TreeView.HitTes t method. When the
        MouseMove event fires, it passes a MouseEventArgs argument to the event
        handler. This contains the XY coordinates of the mouse relative to the
        Control. You can take the X and Y values and pass them to the
        TreeView.HitTes t method, which returns a TreeViewHitTest Info instance that
        contains the TreeNode that the mouse is over (if any). You can use this to
        get a handle on the TreeNode and assign the ToolTipText prior to the
        MouseHover event, which happens only when the moust *stops* moving over a
        Control for a period of several milliseconds. Then, assuming you've turned
        on the ShowNodeToolTip s property, you shouldn't have to handle any other
        events.

        --
        HTH,

        Kevin Spencer
        Microsoft MVP
        Professional Chicken Salad Alchemist

        Big thicks are made up of lots of little thins.


        "sianan" <smartin5321@td s.net> wrote in message
        news:1151476680 .430250.147460@ d56g2000cwd.goo glegroups.com.. .[color=blue]
        > Thanks Kevin,
        >
        > I still can't make it work though. Not sure how I should implement the
        > ToolTip and associate it with the selected node. Here's what I've got:
        >
        > private void myTreeView_Node MouseHover(obje ct sender,
        > TreeNodeMouseHo verEventArgs e)
        > {
        > e.Node.ToolTipT ext = "descriptio n";
        >
        > }
        >
        > Something is obviously missing (just can't figure it out).
        >
        > Thanks!
        >
        >
        >
        > Kevin Spencer wrote:[color=green]
        >> Handle the NodeMouseHover event of the TreeView. It contains arguments
        >> that
        >> indicate which node is being hovered over. Then all you have to do is
        >> implement a ToolTip (or rool your own), and display it wherever you want
        >> to,
        >> in whatever way you want to.
        >>
        >> --
        >> HTH,
        >>
        >> Kevin Spencer
        >> Microsoft MVP
        >> Professional Chicken Salad Alchemist
        >>
        >> Big thicks are made up of lots of little thins.
        >>
        >>
        >> "sianan" <smartin5321@td s.net> wrote in message
        >> news:1151201316 .872428.28930@u 72g2000cwu.goog legroups.com...[color=darkred]
        >> > Hi,
        >> >
        >> > I want to display a 'hover box' (for want of a better description) when
        >> >
        >> > the mouse hovers over a node in a tree view. The box would display
        >> > detail information for the node. It should be small, something like a
        >> > tool tip.
        >> >
        >> >
        >> > Does anyone have any idea of how to do this? I would really appreciate
        >> > any assistance, especially a code snippet or two.
        >> >
        >> >
        >> > Thanks!
        >> >
        >> >
        >> > ~ Si
        >> >[/color][/color]
        >[/color]


        Comment

        Working...