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/>
> >
>
>
>