> Visual Studio .NET lets me to choose an object type (not an instance)
> for the datasource of a datagridview control. Then it automatically
[quoted text clipped - 3 lines]
> instance of a collection object for the datagridview? If there is a
> tutorial page for this task, please direct me there. Thank you.
I found that the reason nothing came up on the control was that my
object has no properties but public fields. I created a property and
it was shown. I wonder if I have to make them all properties instead
of public fields, because that object has no operations and doesn't
need to validate the value of its public fields.
Marc Gravell - 01 Mar 2008 23:23 GMT
> I wonder if I have to make them all properties instead
> of public fields, because that object has no operations and doesn't
> need to validate the value of its public fields.
The standard approach is, indeed, to use properties. Even if you don't
have validation.
With C# 3 you can make this as easy as fields using the new auto-
implemented property syntax:
public int Foo {get;set;}
I *strongly* recommend using properties. However, I have seen a
TypeDescriptionProvider implementation that exposed the fields via
runtime PropertyDescriptors, which allows binding to property-grids,
data-grid-view, etc. But I don't recommend it.
Marc
Michel Walsh - 03 Mar 2008 19:58 GMT
If you still can put you hand on it, this book has 2 nice chapters about
data source binding:
http://www.amazon.com/Windows-Forms-Programming-Microsoft-Development/dp/0321267
966/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1204574054&sr=1-1
It is a kind of 'historical progression' about data binding, but it may help
to understand the mechanic behind, which can be useful, on occasions.
Vanderghast, Access MVP
> Visual Studio .NET lets me to choose an object type (not an instance)
> for the datasource of a datagridview control. Then it automatically
[quoted text clipped - 3 lines]
> instance of a collection object for the datagridview? If there is a
> tutorial page for this task, please direct me there. Thank you.
I found that the reason nothing came up on the control was that my
object has no properties but public fields. I created a property and
it was shown. I wonder if I have to make them all properties instead
of public fields, because that object has no operations and doesn't
need to validate the value of its public fields.