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

Listbox.SelectedObjectCollection

P: n/a
I've added objects to a listbox using

lst.DisplayMember = "CustomerName"
lst.Items.Add(New CCustomer( theData("ID"), theData("CustomerName")))

if I used lst.SelectedIndex I always get the last item in the list irrespective of whether it was selected. So I thought perhaps I should be using the SelectedObjectCollection.

I can't figure out how to use it, can someone show me some example code

I was thinking

for each obj in lst.SelectedObjectCollection

but the compiler doesnt like this it says
"SelectedObjectCollection is a type and cannot be used in an expression"

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


P: n/a
Hi,

Use SelectedItems instead.

Ken
-------------------
"Tony" <To**@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
I've added objects to a listbox using

lst.DisplayMember = "CustomerName"
lst.Items.Add(New CCustomer( theData("ID"), theData("CustomerName")))

if I used lst.SelectedIndex I always get the last item in the list
irrespective of whether it was selected. So I thought perhaps I should be
using the SelectedObjectCollection.

I can't figure out how to use it, can someone show me some example code

I was thinking

for each obj in lst.SelectedObjectCollection

but the compiler doesnt like this it says
"SelectedObjectCollection is a type and cannot be used in an expression"

Thanks

Nov 20 '05 #2

P: n/a
Hi,

Use SelectedItems instead.

Ken
-------------------
"Tony" <To**@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
I've added objects to a listbox using

lst.DisplayMember = "CustomerName"
lst.Items.Add(New CCustomer( theData("ID"), theData("CustomerName")))

if I used lst.SelectedIndex I always get the last item in the list
irrespective of whether it was selected. So I thought perhaps I should be
using the SelectedObjectCollection.

I can't figure out how to use it, can someone show me some example code

I was thinking

for each obj in lst.SelectedObjectCollection

but the compiler doesnt like this it says
"SelectedObjectCollection is a type and cannot be used in an expression"

Thanks

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.