Drag (from ListBox) and Drop (to Finder)

I used the following code from the Documentation:

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

Run the project, choose some Rows from the ListBox and drag them to the Finder. To my great surprise, I got 98 .textClipping files !

Of course, I do not read the sample code before testing it to know if it feed my needs. I thing a small change in the Drag.Text filling line will avoid this flood of textClipping…

So, now you are aware !

Yes, if I want every selected Rows in one file, I’d better use:

[code]Dim nRows, i as Integer
Dim SelText As String

nRows=Me.ListCount-1
For i=0 to nRows
If Me.Selected(i) then
Drag.AddItem(0,0,20,4)

  SelText = SelText + Me.Cell(i,-1) + EndOfLine //get text
End if

Next

// Drag the text…
Drag.Text = SelText

Return True //allow the drag[/code]

[quote=133150:@Emile Schwarz]Yes, if I want every selected Rows in one file, I’d better use:

[code]Dim nRows, i as Integer
Dim SelText As String

nRows=Me.ListCount-1
For i=0 to nRows
If Me.Selected(i) then
Drag.AddItem(0,0,20,4)

  SelText = SelText + Me.Cell(i,-1) + EndOfLine //get text
End if

Next

// Drag the text…
Drag.Text = SelText

Return True //allow the drag[/code][/quote]

You may not want to use ‘Seltext’ as variable name, since it is also the name of a property and can create unexpected bugs or compilation errors.

So, it will be TextSel !

Thanks…