DesktopListBox.DragReorderRows

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Event


DesktopListBox.DragReorderRows(newPosition As Integer, parentRow As Integer) As Boolean

New in 2021r3

Supported for all project types and targets.

This event is called when one or more rows are selected then moved to a new position. The AllowRowReordering property must be True in order for this event to be called.

Notes

When no expandable rows are present

  • The newPosition parameter is the row number at which the dragged row was dropped. Remember that the first row in a DesktopListBox is numbered zero. This row number is adjusted assuming that all selected rows will be moved as implied by the drag & drop action.
  • The parentRow parameter will always be -1, because it has no significance for a non-hierarchical DesktopListBox.

The row(s) to be reordered are selected before this event fires. If the RowSelectionType is set to single, you can use SelectedRowIndex to get the number of the only selected row. If the RowSelectionType is set to multiple, you must go through all rows in the list and check if RowSelectedAt is True for each row (see example in RowSelectedAt).

When DesktopListBox.AllowExpandableRows is False, row reordering is done for you if you return False. To override the automatic behavior so you can do the row reordering yourself (for customization purposes), return True.

When expandable rows are present

  • The newPosition parameter is the row number at which the dragged row was dropped. Remember that the first row is numbered zero.
  • If the newPosition is inside an expandable row (see AddExpandableRow and AddExpandableRowAt) the parentRow parameter is the row number that expandable row, i.e. the parent of the newPosition. Otherwise, parentRow will be -1. This happens if the newPosition is before the first expandable row in the list, i.e. the root level of the DesktopListBox.
  • For both parameters, the row numbers are adjusted assuming that all selected rows will be moved as implied by the drag & drop action.

The row(s) to be reordered are selected before this event fires. If the RowSelectionType is set to single, you can use SelectedRowIndex to get the number of the only one selected row. If the RowSelectionType is set to multiple, you must go through all rows in the list and check if RowSelectedAt is True for each row (see example in RowSelectedAt).

When AllowExpandableRows is True, row reordering is NOT done for you, regardless of the value you return. You are responsible for writing the code for reordering the rows and you should return True.