I would like using a DataReader to fille a listbox with descriptions, on the
other hand i need to store somwhere an ID (to the respective Descriptions),
that i can use as a key when a listbox item has ben selected.

I know i can use a second invisible listbox that stores the ID's in it, but
are there alternatives to solve this problem (with a DataReader) more
elegant? Maybe using the Tag property?

Thanks
Guy

Re: ListBox, DataReader, ID and Description by Herfried

Herfried
Sat Dec 04 05:25:18 CST 2004

"Guy Dillen" <guy_dillen@nospam.hotmail.com> schrieb:
>I would like using a DataReader to fille a listbox with descriptions, on
>the other hand i need to store somwhere an ID (to the respective
>Descriptions), that i can use as a key when a listbox item has ben
>selected.

Take a look at the control's 'DisplayMember', 'ValueMember', and
'DataSource' properties.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Re: ListBox, DataReader, ID and Description by Guy

Guy
Sat Dec 04 05:56:45 CST 2004

Ok, i already did, but does DataSource/DisplayMember/ValueMember also work
with a DataReader?

Guy


"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23q41vPf2EHA.1292@TK2MSFTNGP10.phx.gbl...
> "Guy Dillen" <guy_dillen@nospam.hotmail.com> schrieb:
>>I would like using a DataReader to fille a listbox with descriptions, on
>>the other hand i need to store somwhere an ID (to the respective
>>Descriptions), that i can use as a key when a listbox item has ben
>>selected.
>
> Take a look at the control's 'DisplayMember', 'ValueMember', and
> 'DataSource' properties.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>



Re: ListBox, DataReader, ID and Description by Nicola

Nicola
Sat Dec 04 07:35:03 CST 2004

I don't think it's possible, but why use DataReader ???
I implemented it filling a table, added to a DataSet through a DataAdapter:

Dim DS as DataSet
Dim N as string="TableName"
Dim SQL as string="SELECT * FROM ..."
Dim CN as New SQLConnection(ConnectionString)
Dim CMD As New SqlCommand(SQL, CN), DA As New SqlDataAdapter(CMD)
DS.Tables.Add(N) : DA.Fill(DS.Tables(N))
ListBox.ValueMember = ID
ListBox.DisplayMember = Description
ListBox.DataSource = DS.Tables(N)
ListBox.SelectedIndex = -1 : ListBox.SelectedIndex = -1

I hope this can help You
nq





"Guy Dillen" wrote:

> Ok, i already did, but does DataSource/DisplayMember/ValueMember also work
> with a DataReader?
>
> Guy
>
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:%23q41vPf2EHA.1292@TK2MSFTNGP10.phx.gbl...
> > "Guy Dillen" <guy_dillen@nospam.hotmail.com> schrieb:
> >>I would like using a DataReader to fille a listbox with descriptions, on
> >>the other hand i need to store somwhere an ID (to the respective
> >>Descriptions), that i can use as a key when a listbox item has ben
> >>selected.
> >
> > Take a look at the control's 'DisplayMember', 'ValueMember', and
> > 'DataSource' properties.
> >
> > --
> > Herfried K. Wagner [MVP]
> > <URL:http://dotnet.mvps.org/>
> >
>
>
>