Question Multiple selection ListBox click order

Is this what you mean/want?
VB.NET:
'Class variable
Dim myArr As New List(of String)
'listbox1.SelectedIndexChanged Event:
Dim i As String = listBox1.SelectedItem
myArr.Add(i)
'then in a button click for 1 example: 
For Each i as string in myArr
textbox1.Text &= i & ", "
Next
But it really depends on where you want to send it!
 
Is this what you mean/want?
VB.NET:
'Class variable
Dim myArr As New List(of String)
'listbox1.SelectedIndexChanged Event:
Dim i As String = listBox1.SelectedItem
myArr.Add(i)
'then in a button click for 1 example: 
For Each i as string in myArr
textbox1.Text &= i & ", "
Next
But it really depends on where you want to send it!

Thanks man, That's what I need. I will export it to text file. I know how. Thanks again!
 
Set the SelectionMode to MultiSimple, this also makes keeping track of the click order much simpler:
VB.NET:
Private clickorder As New List(Of Integer)

Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
    Dim itemIndex As Integer = Me.ListBox1.IndexFromPoint(e.Location)
    If itemIndex <> ListBox.NoMatches Then
        If Me.ListBox1.GetSelected(itemIndex) Then
            clickorder.Add(itemIndex)
        Else
            clickorder.Remove(itemIndex)
        End If
    End If        
End Sub
At any time to have a look at the order the currently selected items was selected:
VB.NET:
Dim builder As New System.Text.StringBuilder
builder.AppendLine("the items was selected in this order:")
For Each ix As Integer In clickorder
    builder.AppendFormat("index {0}: {1}" & vbNewLine, ix, Me.ListBox1.Items(ix))
Next
MessageBox.Show(builder.ToString)
 
Back
Top