473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Listbox.SelectedObjectCollection

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
2 4649
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
0
by: mostafa atalla | last post by:
please , can any body help me ... I was making an application using c# to retrieve from and update a database , I created two ListBoxes ,ListBox 1 is linked by a table column in the database ,and...
4
by: mostafa atalla | last post by:
How can I remove some selected items from the listBox in the run time ??
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
11
by: Robin Tucker | last post by:
SelectedItems and SelectedIndices appear to be read-only, so I cannot remove a selected item. I need to do this to synchronise the selection in my list with the selection in other views (ie....
0
by: Tony | last post by:
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...
28
by: cjobes | last post by:
Hi all, I need to populate a listbox from a table column. The column has multiple entries of usernames and I need to pull a unique set of usernames. The table is part of an untyped Dataset that...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
1
by: lance2001 | last post by:
Hi, After viewing the entire Visual Basic 2005 Express Edition for Beginners video series, I have begun building a database driven application that will make use of listbox1 (multi-select)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.