RE: C# question, binding arrays of objects to a list box, can it be done?

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 15 Aug 2009 23:53:37 -0400

 

 

Ok maybe I was not clear enough.  So this time I looked it up on line the
property you're looking for is called itemdata and you can do even more than
I thought with it.  You could save an index to the list of data you have so
if it gets sorted you still know where to look but far better just to attach
the data to the list box.  Now I know I suck at describing this so like I
said I found you an article.  Here it is:

 

http://www11.brinkster.com/notbono/vbnet.asp

 

Ken

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Christy Schulte
Sent: Saturday, August 15, 2009 11:08 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: C# question, binding arrays of objects to a list box, can it be
done?

 

Oh, not sure if this makes a difference, but I'm not actually working with
database files here. I'm using a text file, reading line by line to populate
the object properties. Most information I can find on datasource has to do
with databases.

 

 

 

----- Original Message ----- 

From: Ken Perry <mailto:whistler@xxxxxxxxxxxxx>  

To: programmingblind@xxxxxxxxxxxxx 

Sent: Saturday, August 15, 2009 10:02 PM

Subject: RE: C# question, binding arrays of objects to a list box, can it be
done?

 

 

 

I would have to try this but if you do this in c# data source can be
anything from an int to any kind of structure you want.  So you could just
save the index in the list of data structures in data source or you could
actually use the list box to save your data structures in the data source
field.  

 

Ken

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Christy Schulte
Sent: Saturday, August 15, 2009 10:16 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: C# question, binding arrays of objects to a list box, can it be
done?

 

Ok, let me see if I can explain the problem. I have a feeling I'm missing
something obvious here, but I had a similar hang up in one of my VB
assignments so, who knows.

 

This assignment is to create an address book application. The user is
supposed to have the option to show a list box with all entries listed, but
only show the last name and first name. The full entries include first name,
last name, address among other things. The list box also must be sorted
alphabetically. We're reading the initial entries from a file, but allowing
for edits, additions, deletions, etc.

 

The way I'm doing this is that I created a class called entry, which has
properties for first name, last name, address and so on. Then I have an
array of entry objects, so that for example to get the first name of the
third entry, I could use entries[2].FirstName.

 

So far so good, but I'm at a loss for how to get the information I want into
the list box in such a way that the first and last names displayed there
will stay connected with the rest of their object if deletions and edits are
made. I keep thinking that datasource should play a part here, but when I
research it it's either not what I want, or the explanation is way over my
head. So am I going about this all wrong, or am I just missing something
simple? One thing I considered is keeping name as a single property rather
than trying to pull two different properties into the list together, but
that still doesn't solve the problem of how to keep everything together when
changes are made through the list.

 

I hope this makes some kind of sense, I know what I want to do but not how
to explain it well or how to get it working. Any ideas would be greatly
appreciated.

  _____  


No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.58/2304 - Release Date: 08/15/09
06:10:00

Other related posts: