I'm Posting this here as I had a lot of trouble finding a solution that fit what I needed.
Basically I have a ListBox that drops down from a text field and populates with items, however hovering the mouse over an item had zero effect on the display of the items, selecting an option closes the listbox so using listbox.selecteditem = x wasn't working for me. Neither was any draw method mentioned while searching. This is what I came up with to Highlight an Item in the listbox without triggering the listbox's SelectedIndexChanged property until I needed it.
Code:Dim trigger As Boolean Private Sub listtake_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listtake.SelectedIndexChanged If trigger = True Then Exit Sub End If takenametxt.Text = listtake.SelectedItem.ToString listtake.Items.Clear() listtake.Visible = False End Sub Dim item As Decimal Private Sub ListBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles listtake.MouseMove trigger = True item = listtake.IndexFromPoint(New Point(e.X, e.Y)) listtake.SelectedIndex = item End Sub Private Sub listtake_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles listtake.MouseUp listtake.SelectedIndex = -1 trigger = False listtake.SelectedIndex = item End Sub




Reply With Quote
