Hover selection on listbox

Hi,
Is there any example how to make hover selection in a listbox?
something like,
on listbox1.mousemove event,
listbox1.ListIndex=Listbox1.ListIndex + y

but its does not work properly.

thanks
regards,
Arief

A listbox entry is not hovered, but selected directly.

Isn’t it possible to select the Row below the MouseCursor in the MouseMove Event ?

It is.

1 Like

I had that in mind yesterday, but it was late (time to bed) and I was not sure it was a good idea.

I was busy all day 'till minutes ago.

This should do it.

Sub MouseMove(X As Integer, Y As Integer) Handles MouseMove
  me.SelectedRowIndex = me.RowFromXY( X, Y )
End Sub

If Y is from the event then I think it is the Y pixel position. You should be able to turn that into a row index via one of the listbox methods (RowFromXY?). You may also have to offset the value returned from the function by the listbox’s vertical scroll position.

RowFromXY accounts for scroll position.

1 Like

Thanks !

1 Like

Happy to help!

Arief, Anthony:

Merci !

The question (and its answer) stayed in my mind until earlier this morning: I implemented it in a project and display the selected Row “on the fly” into a bunch of TextField/TextArea (multi lines).

I showed the result (1 hour of work) to the application user and he was delighted.

Nota: at first, I was asking myself what use can this be ? :wink:

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.