Pete,
How can he use the bindingmanager as he does not know the datasource, as
well how can he even get any data in a datagrid without a datasource?
I am really curious as you can show me how?
The documentation for the currencymanager is easy to find by the way and I
will not call this bad.
http://msdn.microsoft.com/library/d...stemwindowsformscurrencymanagerclasstopic.asp
Cor
Having implemented a hierarchical databound grid using the CurrencyManager,
I can promise you that the existing documentation was far from sufficient.
Were it not for tools like Reflector, it simply would have been impossible.
I'm sorry I wasn't more clear in my response. He may not know the specifics
of what the datasource is. That is to say, it could be a DataSet, a
DataTable, or any other IList or IListSource provider. Certainly he can get
the DataSource from the grid and he could then try to determine its type,
but from a generic point of view, he'd probably need to use the
CurrencyManager to then iterate through the data.
Now, one of the problems with doing this is that by iterating through the
CurrencyManager, he then going to implicitly force all bound controls to
iterate through the data as the Position changes. He could get around this
by creating a new BindingContext object and getting the CurrencyManager
from that, but the easiest thing would simply be to go through the grid.
As for the documentation issues, here's an example: The documentation says,
the CurrentChanged event "Occurs when the bound value changes." Well, that's
not very accurate at all. Changes how? If a value in a row in a bound
DataTable is changed? If the current row index (or CurrencyManager.Position)
changes?
The fact is, the CurrentChanged is sent for a variety of operations. If the
source implements IBindingList, then any ListChanged events will trigger a
CurrentChanged, regardless of whether the current item is the item affected
or not. Several other operations trigger a CurrentChanged whether or not the
record at the current CurrencyManager.Position is involved or not.
So the documentation for that one event is seriously misleading.
The MetaDataChanged event says that it "Occurs when the metadata of the List
has changed." Again, misleading in that it doesn't go on to say that this
only applies to objects that implement IBindingList. Any object implementing
IList but not IBindingList will not trigger a MetaDataChanged event if the
metadata of the list changes.
So yes, technically, it's documented, but the documentation is sorely
lacking in my opinion. I could go on and on all day about things about the
CurrencyManager that don't agree with the documentation. I'm intimately
familiar with both.
Pete