Richard Comito
asked on
How do I find all that is selected on a ListBox set up for SelectionMode to be MultiSimple.
I have a list box that can have more then one item selected. But when I do a SelectedValue on the control, all I get is the first value in a string. This is what I have right now.
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Me.txtSubject.Text = Me.lbDBRecipients.Selected Value.ToSt ring
End Sub
Thanks.
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Me.txtSubject.Text = Me.lbDBRecipients.Selected
End Sub
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is how I have changed the the code:
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Dim selIndices As ListBox.SelectedIndexColle ction = lbDBRecipients.SelectedInd ices
Dim strEmailList As String
strEmailList = ""
For i As Integer = 0 To selIndices.Count - 1
strEmailList = strEmailList & lbDBRecipients.Items.Item( selIndices (i)).ToStr ing
Next
Me.txtSubject.Text = strEmailList
End Sub
and this is the result I get:
System.Data.DataRowViewSys tem.Data.D ataRowView System.Dat a.DataRowV iew
Now how do I pull out the value to the selIndices?
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Dim selIndices As ListBox.SelectedIndexColle
Dim strEmailList As String
strEmailList = ""
For i As Integer = 0 To selIndices.Count - 1
strEmailList = strEmailList & lbDBRecipients.Items.Item(
Next
Me.txtSubject.Text = strEmailList
End Sub
and this is the result I get:
System.Data.DataRowViewSys
Now how do I pull out the value to the selIndices?
ASKER
ZeonFlash,
This is what I finally came up with:
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Dim selIndices As ListBox.SelectedIndexColle ction = lbDBRecipients.SelectedInd ices
Dim strEmailList As String
strEmailList = ""
For i As Integer = 0 To selIndices.Count - 1
strEmailList = strEmailList & selIndices(i).ToString & ","
Next
Me.txtSubject.Text = strEmailList
End Sub
Thanks for your help. However I will have to give this a B because I ended up doing all the trouble shooting myself.
This is what I finally came up with:
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Dim selIndices As ListBox.SelectedIndexColle
Dim strEmailList As String
strEmailList = ""
For i As Integer = 0 To selIndices.Count - 1
strEmailList = strEmailList & selIndices(i).ToString & ","
Next
Me.txtSubject.Text = strEmailList
End Sub
Thanks for your help. However I will have to give this a B because I ended up doing all the trouble shooting myself.
ASKER
thank for your reply. I copied and pasted what you wrote but cam up with this error:
Operator '&' is not defined for string "Selected Item #0 = " and type 'DataRowView'.
Thanks