guy,
BindingList does not expose an Items collection as BindingList itself is the
"items" collection.
Instead of:
| For Each thing as Object in myBindingList.Items
Use:
For Each thing as Object in myBindingList
FWIW: If you have a type that has an "Items" collection that suggests that
you have a type that *has* a collection. Classes such as BindingList (that
have a Count & Item properties, GetEnumerator method) *are* a collection.
Generally For Each requires that the type implement IEnumerable or
IEnumerable(Of T). However For Each can operate on types that have a
GetEnumerator method without implementing either interface... Unfortunately
I don't have the link handy on the specifics of what For Each looks for...
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
| Hi Armin,
| my thought was that you cant do a
|
| For Each thing as Object in myBindingList.Items
|
| you have to do something like
|
| For i=1 to myBindingList.Count
| thing=myBindingList.Item(i)
|
| i just wondered why it was designed this way
|
| cheers
|
| guy
|
| "Armin Zingler" wrote:
|
| > > why is it that some collection classes, eg BindingList, but others
| > > as well do not expose their Items property? It is there as a
| > > Protected property so why not make it public?
| > >
| > > I can work around this but there must be a design reason for this,
| > > what is it?
| >
| >
| > BindingList: "Search found no results"
| >
| > System.Windows.Forms.BindingsCollection.Item, if you mean that, is
public.
| >
| >
| > Armin
| >