Row index when dropping file on a Listbox

Hi,

is there a way to know on which row of a listbox I dropped a file? I was thinking of using the x,y position of DragOver but that works unless you scrolled down the listbox…
Any ideas?

Thanks.

I solved in this way:

row = Me.ScrollPosition + (obj.DropTop + obj.DropHeight/2) \\ Me.DefaultRowHeight

What you want is ListBox.RowFromXY

No, because in the DropObject handler you don’t have x and y…

It looks like you can access the x and y via the object that was dropped.
DragItem.DropTop and .DropLeft
http://documentation.xojo.com/index.php/DragItem.DropLeft

This is untested speculation based on reading the docs.

yes that’s how I solved:

row = Me.ScrollPosition + (obj.DropTop + obj.DropHeight/2) \ Me.DefaultRowHeight

In my latest application I needed to use RowFromXY and ColumnFromXY in windows that are not in front. Unfortunately, the result is always zero, so I ended up brewing my own with the same principle as what Davide posted.

Function RowfromY(extends LB as Listbox, Y as Integer) As Integer dim offset as integer = floor(Y/LB.RowHeight) Return LB.ScrollPosition+offset End Function

In my brief testing, Tim P’s .dropLeft and .dropTop solution works. One just needs to accurately calculate in what cell the results will fall. Of course, if the listbox scrolls, those calculations become quite complex.