c# - When setting the DataSource property of an object, when do you use a Type vs. an instance? -
question
what difference between setting [...].datasource
instance of object vs. type of class? have seen both methods in use in our codebase, , i'm trying wrap head around why 1 way or other in of these cases.
example
how does
object1.datasource = typeof(someclass);
differ from
object2.datasource = getsomeobject();
further inquery
also, in first case, if set datasource
type of class, happens if class base class? data binding work on properties exist in classes descend base class? or data binding work on class members of type of class set datasource
to?
i'm having hard time wording google
search queries give me answer question. , either because stuff complicated , i'm not wording right, or not quite understand of fundamentals of data binding in c#. getting pointed in right direction here? thanks!
when set bindingsource.datasource
property type control bound empty ibindinglist
elements of type. data source have no items. if on other hand set datasource
collection of items data source bound ibindinglist
these items.
so assigning type gives empty list of items while assigning collection gives list items collection.
if assign base type empty list of base type items. data binding not "know" derived classes.
Comments
Post a Comment