Listbox multi-columns drag drop between two listbox

Hi,
I found the code on the LR , to do row dragging between two listboxes.

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) 
    End If
    drag.Text = Me.List(i)
  End If
Next

Return True

this is works nicely when the listbox is single-column.

how to make it work will multi-column.

any helps,
thanks
arief

Hi,

Replace this:

By something like this:

Var ColumnsOnThisRow() As String
for j as Integer=0 to me.ColumnCount-1
  ColumnsOnThisRow.Add me.CellTextAt(i,j)
Next
//Now, ColumnsOnThisRow contains all the columns you need.
drag.Text=String.FromArray(ColumnsOnThisRow,Encodings.UTF8.Chr(9)) //Tab-separated values

HTH.

1 Like

hi,
I still got an error here. i can’t found 'add function on a string.

i am still using old version 2021 r1.1. but do the test on 2022 r1.1 also shows the same error.

thanks
arief

What error do you get?
If you type ColumnsOnThisRow. and then press TAB what autocomplete shows?

When I press the tab and change celltextat into cellvalueat is working now.
but it wont stay on proper column.
the text from source listbox both text from column 0 and 1, placed on column 0 separated by tab.

thanks
arief

Well, of course you have to do the opposite when receiving the drag. The target listbox must know how to split back the dragged, packaged columns, back to each column.

thanks.

regards,
arief