473,395 Members | 1,411 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,395 software developers and data experts.

Assigning Array variables to a list box

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

Similar topics

1
by: dSchwartz | last post by:
This may not be a big deal, but I'm just kinda curious. If I have a page that submits a form to itself, when is it better to assign each element in $_POST to a variable to use for the rest of the...
1
by: Cory Bosma | last post by:
Looked all over for the answer to this but can't find it. Maybe I'm searching for the wrong thing. I'm new to using classes in PHP. Whenever I try and reference the member's ($line) properties...
3
by: Ben | last post by:
Hi all, This may sound easy but I'm having trouble assigning values to array element. My problem is as follows: m = for o in m: # Here first o is 'Peter'.. I want to do something like this:...
10
by: Matthew Sims | last post by:
Python Newbie here. This is my first time learning object-oriented programming and trying to break out of the usual Korn/Perl/PHP style of programming. Having some difficulty understand some items....
28
by: anonymous | last post by:
I have couple of questions related to array addresses. As they belong to the same block, I am putting them here in one single post. I hope nobody minds: char array; int address; Questions...
14
by: ranjmis | last post by:
Hi all, Below is the code wherein I am initializing double dimentional array inside main with string literals. Now I want to display the strings using a function call to which I just want to...
7
by: 7h | last post by:
Sorry if I sounds like a noob (because I am one, here). I ran across this earlier, and it kept bugging me. I guess someone here know a good answer. To summerize, I was using array within a...
2
by: want2learnperl | last post by:
Perl Newbie here. I want to open a file that I have setup as a configuration file. After opening the file I was to assign parts of the words to variables. for example (configuration file...
37
by: miken32 | last post by:
In PHP, if a function returns an array it's fairly common to capture its return values like this: <?php list($foo, $bar, $baz) = some_function_that_return_an_array(); ?> In Javascript, would...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.