Troubles with ListBox (Drag and Drop)

While trying to implement new features (around a ListBox), I fall into that. Go to the Language Reference (or read below the relevant part):

  1. ListBox1.List(RowIndex)
    It returns only Column(0) contents even if the ListBox have more than 1 column.

Not nice.

  1. ListBox2 DropObject code below:
    It add data only in Column(0) even if I change the code from DragRow (below)

Not nice.

Drag and Drop Between ListBoxes The following example allows the user to drag one row from ListBox1 to ListBox2. ListBox1 has its EnableDrag property set to True and its SelectionType property set to zero (Single). Its DragRow event handler is as follows: Function DragRow (Drag as DragItem, Row as Integer) as Boolean drag.text=Me.List(row) Return True //allow the drag

ListBox2’s Open event handler has the line:
Me.AcceptTextDrop

Its DropObject event handler is this:
Sub DropObject (obj as DragItem)
Me.AddRow obj.text //adds the dropped text as a new row

[quote=182721:@Emile Schwarz]1. ListBox1.List(RowIndex)
It returns only Column(0) contents even if the ListBox have more than 1 column.

Not nice.[/quote]
List(rowIndex) is a shortcut for Cell(rowIndex, columnIndex).
Nice.

[quote=182721:@Emile Schwarz]2. ListBox2 DropObject code below:
It add data only in Column(0) even if I change the code from DragRow (below)

Not nice.[/quote]
This is an example for two listboxes with each one column.
Nice.

It is up to you to program the dragging for listboxes with more than one column. For example like that:

[code]// Listbox1
Function DragRow (drag As DragItem, row As Integer) As Boolean
Dim arr() As String
For i As Integer = 0 To Me.ColumnCount - 1
arr.Append(Me.Cell(row, i))
Next
drag.Text = Join(arr, “|”)
Return True
End

// Listbox2
Event Open()
Me.AcceptTextDrop()
End

// Listbox2
Sub DropObject (obj As DragItem)
Me.AddRow obj.Text.Split("|")
End[/code]

Where columnIndex is always 0.

Yes, of course. Sorry for that mistake.

OK. Thank you. I was starting to ask me questions on what I understand and… why I was wrong.

Its bad to become an oldster.

I know, same situation here…