Binding to a c# class

  • Thread starter Thread starter Jellybean
  • Start date Start date
J

Jellybean

Hello,

I believe it is possible to bind controls on forms to object instances,
rather than to datasets.
I need to be able to do this from Datagrid controls, and text box controls.

Regards,
darkspector
 
darkspector,

It is possible to do this. However, if you want to bind a single
instance of a class, you can't bind a data grid to that. The DataGrid class
requires that the data source implement the IList or the IListSource
interfaces. The reason for this is that the grid is meant to show multiple
rows of information, and a single class instance is representative of one
instance.

If you want, you can use the PropertyGrid class to show information
about a single instance.

If you have multiple instances in a collection, for instance (no pun
intended), then you can set the DataSource property of the grid to that
collection that implements IList (and returns the instances of your class),
and then it should bind to that.

Hope this helps.
 
Back
Top