Hi,

I have a simple question about hovering in a checklistbox. How can I get the value(object ) the hovered item..?

I have tried something like this:
Private Sub CheckboxHover(ByVal sender As Object, ByVal e As EventArgs) Handles CheckedListBox1.MouseHover
'MsgBox(sender.GetType.ToString & ", " & e.GetType.ToString)
'Dim mSender As CheckedListBox = sender
ToolTip1.SetToolTip(Me.CheckedListBox1, "s")
End Sub

The eventargs gives no possibilities and I do not know how to get the hovered Item in the sender..?

Recommended Answers

All 4 Replies

I don't know what you are doing but it is the Enter and Leave properties.
Private Sub CheckBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Enter
End Sub

Hi, To get the Hover Item, Use MousePosition property and CheckedListBox.IndexFromPoint Function.

Ex

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i As Integer = 0 To 10
            CheckedListBox1.Items.Add(i)
        Next
    End Sub
    Dim iInd As Integer
    Private Sub CheckedListBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CheckedListBox1.MouseMove
        Dim iMouse As Point
        Dim iNewInd As Integer
        iMouse = CheckedListBox1.PointToClient(Control.MousePosition)
        iNewInd = CheckedListBox1.IndexFromPoint(iMouse)

        If (iNewInd >= 0 And iNewInd < CheckedListBox1.Items.Count) And iInd <> iNewInd Then
            CheckedListBox1.SelectedIndex = iNewInd
            ToolTip1.SetToolTip(CheckedListBox1, CheckedListBox1.Items.Item(iInd))
            iInd = iNewInd
        End If

    End Sub

Wayne, thanks but it was not what I was looking for..

Selvaganapathy, that was exactly what I wanted.. Nice, thanks a lot.. I just wanted the current selected one so I replaced The iInd with iNewInd but it is exactly what I needed.. :)

Oh Good,

I mistakenly wrote iInd instead of iNewInd in

ToolTip1.SetToolTip(CheckedListBox1, CheckedListBox1.Items.Item(iInd))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.