Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Automatic Data Binding objects in WinForms

I'm used to creating my custom objects and collections (deriving from CollectionBase) in my .NET applications, as opposed to using datasets.

While this approach has served me well in ASP.NET applications, I find myself wondering if it will go as well in WinForm applications.  The team of developers I need to lead are used to using DataSets for its automatic binding and updating ability, but for bigger projects DataSets are just no good, especially given that there may be a lot of web services (ie serialization) to heterogeneous platforms involved.

Does anyone know of any good approaches to make custom objects/collections easily work with WinForms Data Binding and produce some mechanism for updating? Or is this going to involve a whole lot of manual coding work?

I've had a look at CSLA.Net as a possible framework, but didn't really like it, as the layers didn't seem seperated enough and it still seemed to require a whole lot of manual binding and updating.

Thx

Sam
Sunday, June 19, 2005

Sam,

You can bind any property of a Windows Forms control to any property of any object. You can even fake two-way binding. See this article by Ian Griffiths for more details.
http://www.interact-sw.co.uk/iangblog/2004/10/23/propertychange

Mark Pearce
Sunday, June 19, 2005

Mark, thanks.  This PropertyChangeAdapter idea is pretty neat, although I can't get testcode to run correctly for the moment, since it gives me a 'Cannot convert 'Person' to 'IMyPropertyChange' compile error.

Do you need to change anything to your adaptee class (ie Person) in order for this to work? And how does it work on collections?

Cheers

Sam
Monday, June 20, 2005

*  Recent Topics

*  Fog Creek Home