DesktopListBox.DragRow

From Xojo Documentation

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


DesktopListBox.DragRow(Drag as DragItem, Row as Integer) As Boolean

New in 2021r3

Supported for all project types and targets.

The user is dragging a row.

Notes

Drag is the DragItem object that is created automatically. Assign the values to the DragItem’s properties that the user should drag. Row is the row of the ListBox that is being dragged. You must return True in this event handler to allow the drag to occur.

Sample Code

Setting up the DragRow event handler to allow the user to drag a value from a ListBox:

Function DragRow(drag As DragItem, row As Integer) As Boolean
drag.Text = ListBox1.List(row)
Return True
End Function

If you want to allow multiple row selection and dragging, then you need to process all the rows in the selection. This version of the DragRow event handler illustrates this.

Function DragRow(drag As DragItem, row As Integer) As Boolean
Var nRows As Integer
Var additionalItems As Boolean
For i As Integer = 0 To Me.RowCount - 1
If Me.RowSelectedAt(i) Then
If Not additionalItems Then
additionalItems = True
Else
drag.AddItem(0, 0, 0, 0) // No need to specify a rect for just text
End If
drag.Text = Me.List(i)
End If
Next

Return True
End Function