Determine listbox row on mouse over

Is there a way to determine what row the mouse is over (without clicking the row) in a listbox?


ListBox.ColumnFromXY ( X as Integer,Y as Integer ) As Integer
ListBox.RowFromXY ( X as Integer,Y as Integer ) As Integer

hmmmm… i need some help. I have a listbox, and one column contains an image. When the cursor is over the image I want to open a small window with the image enlarged. I can use mouseenter and mouseexit, but how do i determine what row it’s over.

Add EventHandler MouseMove

Sub MouseMove(X As Integer, Y As Integer)
dim row as integer = me.RowFromXY(X, Y)
dim column as integer = me.ColumnFromXY(X, Y)
End Sub

Also watch the ListBox webinar I did last week, which includes an example project that demonstrates how to do this any many other things using a ListBox:

Thank you.

Paul, do you have to approximate time when you talked about this. I’ve watched the video and don’t recall seeing it.

Offhand, no. But check the example project (ListBoxExample) and look at the MainWindow.StandardListBox.MouseMove event handler.

Thanks again.

I’ve already tried something similar. When the cursor is over the cell I want to open a window and display a larger version of the image in the cell. The problem with MouseMove is when/how do I close the window. I also tried MouseEnter and MouseExit, but getting the correct x and y values is a nightmare because of the nested containers I have. Any ideas would be appreciated.

You want to open a Window just by the action of moving a mouse cursor? That seems like bad UI to me as it would be rather jarring with the focus change and all.

Maybe you could just put a companion Canvas on the same Window that is made visible on MouseEnter to show the image and made invisible on MouseExit. MouseMove could get the row/col using as described above and update the Canvas accordingly.

You’ve given me an idea. Thanks. And by the way, the webinar was very informative.