Paul
Sat Nov 26 09:54:52 CST 2005
This showed up while inspecting the DataView class with reflector:
void IList.Clear()
{
throw ExceptionBuilder.CanNotClear();
}public static Exception CanNotClear()
{
return
ExceptionBuilder._Argument(Res.GetString("DataView_CanNotClear"));
}
I was assuming that the ListDictionaryInternal collection class which is
being used inside the DataView class was capable of clearing its values, and
so it seems with reflector. What I overlooked is the DataView class relying
on the IBindingListView (inheriting IBindingList and IList) contract and
thus implements the Clear operation.
Sorry for the wrong link... this would be the correct one
http://msdn2.microsoft.com/library/system.windows.forms.bindingsource.list.aspx.
Hope this clears things up.
###
Best regards,
Paul Gielens
Visit my blog @
http://weblogs.asp.net/pgielens/
"Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message
news:uZGUrKp8FHA.3880@TK2MSFTNGP12.phx.gbl...
>
> Hi,
>
> "Paul Gielens" <pgielens@gmail.com.nospam> wrote in message
> news:uYYHv3o8FHA.3200@TK2MSFTNGP11.phx.gbl...
>>
>> See this
>> (
http://msdn2.microsoft.com/library/system.windows.forms.bindingsource.clear.aspx)
>> example where the table is assigned to the BindingSource.DataSource
>> property. Internally the table its DataRow collection is bound to the
>> connector. The Clear operation now deletes all data rows from your table.
>
> I don't see an example. And when you bind a DataTable then it's
> internally bound to the DefaultView (DataView).
>
> A DataTable isn't directly bindable because it doesn't implement IList, it
> does implement IListSource which provides the DefaultView.
>
> DataTable dt = new DataTable();
> dt.Columns.Add( "test", typeof(string) );
> BindingSource bs = new BindingSource(dt, "");
> Console.WriteLine( bs.List.GetType() ); // prints DataView
> Console.WriteLine( bs.List == dt.DefaultView ); // prints true
>
>
> Greetings
>