drag and drop in hierarchial listbox

I want to be able to drag an item onto a parent item to assign the child to the parent item. How do I determine the index value where the child row is dropped on the List?

Thank you,
Rob

It can be achieved with a little work. When I was learning about hierarchical listboxes, the biggest thing for me the learn was the fact that that the child rows are not really a child of the folder row. When folders are expanded and collapsed the child rows need to be added and deleted by code. So you need to have a way of tracking the child rows in an array or property.

Check out [quote]Examples>Desktop>Controls>ListBox>ListBoxExample.xojo_project[/quote]
and [quote]Examples>Desktop>Controls>ListBox>ListBoxDragBetweenCells.xojo_project[/quote]

The lag shown below when reordering is due to server lag, but it shows what is possible.

[quote=337526:@Neil Burkholder]It can be achieved with a little work. When I was learning about hierarchical listboxes, the biggest thing for me the learn was the fact that that the child rows are not really a child of the folder row. [/code]
I dunno where you got this idea but they definitely are IF you use the expand row event and simply use addrow
They have an indent level that is the parent rows + 1

If you add them in code in the expand row event (or in methods called by that event) then ADDROW definitely adds a child row
And if you collapse the row they disappear

The listbox only has as many rows as are visible.
There are no ‘hidden’ ones waiting to appear when you choose to expand a node: the children are added in the expand event.

To drag an existing visible row onto another visible row, you need to return true in the DragRow event

Then (how I do it)
While the mouse is moving around the list, set the listindex to me wherever the mouse is.
This highlights the potential ‘drop row’

rownum = me.RowFromXY(x,y) if rownum >= 0 and rownum <= me.listcount then me.listindex = rownum end if

Then, when the DropObject event fires, the row you need to add a child to is already the listindex.
I tag the rows with database keys or similar.
So in the DropObject event, I start by getting hold of what I need from the target row

DroppedOntoRef = me.rowtag(me.listindex) DroppedOntoListindex = me.listindex droppedOntoIndent = me.celltag(me.listindex,0)

So now I can add a child to this both visually and in my underlying data model.