The text below comes from the documentation and it does not works as expected at all.
a. Function DragRow code below does not adds multiple Rows (only one at a time),
b. Once you selected two or more Rows from ListBox1 and drag n Drop them, only one (or none) is added to ListBox2
c. I do not recall if this s is this example or the previous one (in the docs), but drag and drop into an open folder (Finder) create as many clippedText as selected Rows
In fact, and after spending some hours on the subject, my deep feeling is that the whole explanation / examples does not works at all.
Tested with Xojo 2015r1 + Xojo 2015r2.2 / Maverick + Yosemite.
BTW: for the proof of concept, and easy to use, I created a brand new project with one window and put two ListBox (ListBox1 and ListBox2) in it. The idea is to drag and drop text data from one ListBox (Application 1) into another ListBox (Application 2) or eventually from ListBox1 in Window1 to ListBox2 in Window2.
Documentation quote:
Drag and Drop Multiple Rows Between ListBoxes
The following example allows the user to drag more than one row from ListBox1 to ListBox2. The dragged rows are added to the end of the list.
ListBox1
has its EnableDrag
property set to True
, enabling items in its list to be dragged, and its SelectionType
property set to 1 (Multiple row selection). Its DragRow
event handler is as follows:
Function DragRow (Drag as DragItem, Row as Integer) as Boolean
Dim nRows, i as Integer
nRows=Me.ListCount-1
For i=0 to nRows
If Me.Selected(i) then
Drag.AddItem(0,0,20,4)
Drag.Text=Me.List(i) //get text
End if
Next
Return True //allow the drag
It uses the AddItem
method of the DragItem
to add an additional item to the DragItem
each selected row. The DropObject
event handler then cycles through all items to retrieve all dragged rows.
ListBox2
has the following line of code in its Open
event handler. It permits it to receive dragged text.
Me.AcceptTextDrop
Its DropObject
event handler checks to see if the dragged object is text; if it is, it adds a row to the end of the list and assigns the text property of the dragged object to the new row: It loops through all items in the DragItem
until NextItem
returns False
.
Sub DropObject(obj as DragItem)
Do
If Obj.TextAvailable then
Me.AddRow(Obj.Text)
End if
Loop until Not obj.NextItem
You can also drag from ListBox1 to the desktop to get a text clipping or to another application that supports text drag and drop.