473,785 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1576
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(listb ox1.SelectedIte ms); ) 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************ ***********@fuj ifilmsericol.co mwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.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
2828
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 page? My situation probably doesn't make a difference, but say I have about 10 form fields, and when the page is posted back to itself, i call each of those form fields 2 times (1 for error checking, 1 for SQL insert, or to pre-fill form). ...
1
1694
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 or functions I either get blank for properties or "Call to a member function on a non-object" for functions. I'm sure I'm doing something incorrectly with the assignment. function LineGroup($classarray) {
3
8278
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: Peter = 10
10
1825
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. For lists, I understand this: C= print C some But I can't seem to do this:
28
2452
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 1: Why cannot I do the following:
14
2360
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 pass the array as argument with no other info like number of strings. Is there a way to achieve that?
7
1347
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 class. After some manipulation, the value of the array's element that I needed wasn't "echoed" right. For instance,
2
1662
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 config.conf): cake=yellow,chocolate,red,white icing=butter,lemon,chocolate
37
2676
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 the equivalent (acceptable) code be this? = some_function_that_return_an_array();
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10085
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.