Mouse over tooltip

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

    Mouse over tooltip

    I have a ListBox, which is binded to a DataTable.
    I would like to display a tooltip when the mouse cursor hovers over the
    items in the ListBox.
    I don't know how to find the index if ListBox item, on which mouse
    cursor is over and how to display the tooltip.
    Any suggestions?

    TIA

  • Dennis

    #2
    RE: Mouse over tooltip

    In the ListBox's "MouseMove" event, you can track the mouse location and set
    form level variables to it's X,Y location. Then in the MouseHover Event, you
    can get the ListBox Index that the mouse is over from the IndexFromPoint
    method and the X,Y form level variables. You can then assign ToolTip.Text
    equal to whatever you want depending on the index that the mouse is hovering
    over. Unfortunately, I haven't found a way to get the tooltip to redisplay
    unless the mouse is moved out of the control then back over the control.

    --
    Dennis in Houston


    "Nikolay Petrov" wrote:
    [color=blue]
    > I have a ListBox, which is binded to a DataTable.
    > I would like to display a tooltip when the mouse cursor hovers over the
    > items in the ListBox.
    > I don't know how to find the index if ListBox item, on which mouse
    > cursor is over and how to display the tooltip.
    > Any suggestions?
    >
    > TIA
    >
    >[/color]

    Comment

    • Dennis

      #3
      RE: Mouse over tooltip

      In the ListBox's "MouseMove" event, you can track the mouse location and set
      form level variables to it's X,Y location. Then in the MouseHover Event, you
      can get the ListBox Index that the mouse is over from the IndexFromPoint
      method and the X,Y form level variables. You can then assign ToolTip.Text
      equal to whatever you want depending on the index that the mouse is hovering
      over. Unfortunately, I haven't found a way to get the tooltip to redisplay
      unless the mouse is moved out of the control then back over the control.

      --
      Dennis in Houston


      "Nikolay Petrov" wrote:
      [color=blue]
      > I have a ListBox, which is binded to a DataTable.
      > I would like to display a tooltip when the mouse cursor hovers over the
      > items in the ListBox.
      > I don't know how to find the index if ListBox item, on which mouse
      > cursor is over and how to display the tooltip.
      > Any suggestions?
      >
      > TIA
      >
      >[/color]

      Comment

      • Ken Tucker [MVP]

        #4
        Re: Mouse over tooltip

        Hi,

        When I use this code the tooltip is always displayed when the mouse
        is over the listbox.

        Private Sub ListBox2_MouseM ove(ByVal sender As Object, ByVal e As
        System.Windows. Forms.MouseEven tArgs) Handles ListBox2.MouseM ove
        Dim i As Integer = ListBox2.IndexF romPoint(e.X, e.Y)

        If i >= 0 Then ToolTip1.SetToo lTip(ListBox2,
        ListBox2.Items. Item(i).ToStrin g)

        End Sub

        Ken
        ---------------------------
        "Dennis" <Dennis@discuss ions.microsoft. com> wrote in message
        news:E164BA8B-E985-45CE-B362-F44AD175811C@mi crosoft.com...[color=blue]
        > In the ListBox's "MouseMove" event, you can track the mouse location and
        > set
        > form level variables to it's X,Y location. Then in the MouseHover Event,
        > you
        > can get the ListBox Index that the mouse is over from the IndexFromPoint
        > method and the X,Y form level variables. You can then assign ToolTip.Text
        > equal to whatever you want depending on the index that the mouse is
        > hovering
        > over. Unfortunately, I haven't found a way to get the tooltip to
        > redisplay
        > unless the mouse is moved out of the control then back over the control.
        >
        > --
        > Dennis in Houston
        >
        >
        > "Nikolay Petrov" wrote:
        >[color=green]
        >> I have a ListBox, which is binded to a DataTable.
        >> I would like to display a tooltip when the mouse cursor hovers over the
        >> items in the ListBox.
        >> I don't know how to find the index if ListBox item, on which mouse
        >> cursor is over and how to display the tooltip.
        >> Any suggestions?
        >>
        >> TIA
        >>
        >>[/color][/color]


        Comment

        • Ken Tucker [MVP]

          #5
          Re: Mouse over tooltip

          Hi,

          When I use this code the tooltip is always displayed when the mouse
          is over the listbox.

          Private Sub ListBox2_MouseM ove(ByVal sender As Object, ByVal e As
          System.Windows. Forms.MouseEven tArgs) Handles ListBox2.MouseM ove
          Dim i As Integer = ListBox2.IndexF romPoint(e.X, e.Y)

          If i >= 0 Then ToolTip1.SetToo lTip(ListBox2,
          ListBox2.Items. Item(i).ToStrin g)

          End Sub

          Ken
          ---------------------------
          "Dennis" <Dennis@discuss ions.microsoft. com> wrote in message
          news:E164BA8B-E985-45CE-B362-F44AD175811C@mi crosoft.com...[color=blue]
          > In the ListBox's "MouseMove" event, you can track the mouse location and
          > set
          > form level variables to it's X,Y location. Then in the MouseHover Event,
          > you
          > can get the ListBox Index that the mouse is over from the IndexFromPoint
          > method and the X,Y form level variables. You can then assign ToolTip.Text
          > equal to whatever you want depending on the index that the mouse is
          > hovering
          > over. Unfortunately, I haven't found a way to get the tooltip to
          > redisplay
          > unless the mouse is moved out of the control then back over the control.
          >
          > --
          > Dennis in Houston
          >
          >
          > "Nikolay Petrov" wrote:
          >[color=green]
          >> I have a ListBox, which is binded to a DataTable.
          >> I would like to display a tooltip when the mouse cursor hovers over the
          >> items in the ListBox.
          >> I don't know how to find the index if ListBox item, on which mouse
          >> cursor is over and how to display the tooltip.
          >> Any suggestions?
          >>
          >> TIA
          >>
          >>[/color][/color]


          Comment

          • Nikolay Petrov

            #6
            Re: Mouse over tooltip

            Thanks Ken

            Comment

            Working...