DataReader and ListBox

  • Thread starter Thread starter eAndy
  • Start date Start date
E

eAndy

oh come on. I have to be missing something.

There HAS to be a better way of binding data to a winform listbox that
reading through all the records and adding each item to the items
collection.

Its .NET for crying out loud.
 
Check out the DataSource property. You can assign a DataView, a collection
object, etc to it in one line and it fills the list box automatically from
the assigned source.

Eric
 
True, but that implies a dataset.I was looking for something more direct.

No reason to make two copies of the data (1 into dataset, then copy into
control, discard dataset).

Looks like looping is the way to go.

Thanks
 
Hi Andy,

listBox in .NET framework can only be bound to object which implements
IList or IListSource. It can't be bound to a datareader. AS you have said,
looping in the datareader and adding items to the ListBox should be a work
around. Anyway, if the records are not huge, binding to a dataset should be
a better solution.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top