ListBox.DragRow

From Xojo Documentation

Event


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

Supported for all project types and targets.

The user is dragging a row. Row is zero-based.

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
Dim nRows As Integer
Dim additionalItems As Boolean
For i As Integer = 0 To Me.RowCount - 1
If Me.Selected(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