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

Assigning Array variables to a list box

P: n/a
Hi all,

I'm trying to add functionality to an app written in C# so that a list
of people is displayed in a list box on the left hand side and then
selected individuals can be added to another list box on the right-hand
side.

I've got the data from my database into a database reader and I can get
it into an arrayList, however I can't get it to do what I want! :)

Basically, I want to use the unique index of my database as the index
for the list boxes, so that I can add a unique ID to the listBox with
an assigned value, the value can be selected, transfereed to the second
Listbox (along with it's value!) and then the database can be updated
accordingly.

Any advice is welcome,

Cheers,

Matt

Nov 3 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
It would be a lot easier if you were working with objects. Examle if you
have a Person class having all the necesary properties, then you would
override ToString() method of your Person class. Then all you need to do is
add the instance of Person to the .Items collection of listbox (ie:
listBox1.Items.Add(person1) ).

Then by grabbing all the selected items from your first list box, you can
add them to you second listbox ie
(listBox2.items.AddRange(listbox1.SelectedItems); ) And when you need to
update your database, you can cast the objects back to Person type, which
will give you all the properties of the object.

hope this helps
Fitim Skenderi


<ma***********************@fujifilmsericol.comwrot e in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi all,

I'm trying to add functionality to an app written in C# so that a list
of people is displayed in a list box on the left hand side and then
selected individuals can be added to another list box on the right-hand
side.

I've got the data from my database into a database reader and I can get
it into an arrayList, however I can't get it to do what I want! :)

Basically, I want to use the unique index of my database as the index
for the list boxes, so that I can add a unique ID to the listBox with
an assigned value, the value can be selected, transfereed to the second
Listbox (along with it's value!) and then the database can be updated
accordingly.

Any advice is welcome,

Cheers,

Matt

Nov 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.