By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,948 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,948 IT Pros & Developers. It's quick & easy.

Retrieving Multiple selected items from a data bound listbox

P: n/a
I have a data bound listbox that I want to select multiple lines then
process each line.
I bound a two column datatable to the listbox and set the DisplayMember
property to the appropriate column of the datatable. I set the
SelectionMode property to MultiExtended.

I am able to load and select multiple lines in the listbox but I can not
figure out how to retrieve both columns for each line selected in the
listbox. I know that there is a SelectedItems collection that contains the
lines selected in the list box but I cannot retrieve both columns for each
item in the SelectedItems collection.

Does anyone know how to accomplish this?

Thanks
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Davix,

What do you mean two columns, the display and the value member?

Than there is as well a property SelectedValue however tell us first if you
mean this?

Cor
I have a data bound listbox that I want to select multiple lines then
process each line.
I bound a two column datatable to the listbox and set the DisplayMember
property to the appropriate column of the datatable. I set the
SelectionMode property to MultiExtended.

Nov 20 '05 #2

P: n/a
Cor,

I have already tried the DisplayMember and the SelectedValue properties.
They only contain the information for the first selected item in the list.
I could not retrieve the values for any other selected items in the list.

Thanks,
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
Hi Davix,

What do you mean two columns, the display and the value member?

Than there is as well a property SelectedValue however tell us first if you mean this?

Cor
I have a data bound listbox that I want to select multiple lines then
process each line.
I bound a two column datatable to the listbox and set the DisplayMember
property to the appropriate column of the datatable. I set the
SelectionMode property to MultiExtended.


Nov 20 '05 #3

P: n/a
Hi David,

A real challenge to find I think it is this

I hope it helps?

Cor
\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim ar(ListBox1.SelectedItems.Count) As String
For i As Integer = 0 To ListBox1.SelectedItems.Count - 1
ar(i) = DirectCast(ListBox1.SelectedItems(i),
DataRowView)(1).ToString
Next
End Sub
///
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.