Re: Could someone please explain by Beringer
Beringer
Tue Jul 27 21:49:15 CDT 2004
I understand the properties but don't understand where "EmpID" and "EmpName"
come from.
What are these names of? What kind of object do they belong too?
ArrayList, Class etc.
See I assume you set the DataSource to an object like an arraylist. Using
your example:
struct Employee
{
int EmpId;
string EmpName;
....other code for structure
}
ArrayList Employees;
(add empolyees to the list)
ListControl.DataSource = Employees;
ListControl.DisplayMember = "EmpName";
ListControl.DisplayValue = "EmpId";
blah, blah, blah....
The above will throw an exception, saying something like "Can't Set
DisplayMember".
Thanks again,
Eric
"Joyjit Mukherjee" <joyjit_mukherjee@hotmail.com> wrote in message
news:%23pZyZJ6cEHA.1424@tk2msftngp13.phx.gbl...
> Hi,
> DisplayMember displays the the list of values for the list control,
whereas
> ValueMember is the value the control hold for account for that
DisplayMember
> when you select or change the display. e.g.
>
> EmpId EmpName
> 101 Roger
> 102 John
> 103 Micheal
>
> Here, you set the DisplayMember & ValueMember as EmpName and EmpId resp.
> Now, when you select or change the EmpName, the corrosponding EmpId is
> picked up for calculation. Is that clear ?
>
> Regards
> Joyjit
> "Beringer" <borden_eric@invalid.com> wrote in message
> news:_1mNc.10221$8G6.6373@fed1read04...
> > I'm trying to set a datasource of a combobox to an ArrayList and want to
> set
> > the DisplayMember and ValueMember properties of the combobox to items in
> the
> > ArrayList.
> >
> > I reviewed the example with US States found in VS but don't understand
how
> > setting the DisplayMember and ValueMember properties works.
> > The member properties are to be set to string values of the names of the
> > properties to use in the DataSource. This doesn't make sense to me.
What
> > are the properties of an ArrayList that can be used?
> >
> > Thank you in advance,
> > Eric
> >
> >
>
>