views:

224

answers:

2

Hello Everyone,

I have an existing C# 3.0 WinForms project with .NET 3.5 that talks to a MySQL database. I would like to use data binding (I'm new to this, so I've been doing all of the UI updates manually) to simplify things.

I followed a link from this question to this article which mentions using a DataSet but also follows up with "my view on this topic is strongly in favor of Business Objects." Also that was with .NET 2.0.

What are the current methods to use data binding with a WinForms application? What are their advantages in terms of simplicity, how much additional code is necessary, etc.

For reference, I use an ORM approach to build objects with public properties from a database. I want to map these properties for each object onto UI elements like TextBoxes. There could be many properties for an object so I want to simplify the code to do this.

+1  A: 

Personally I've found that an MVP-VM pattern works quite well for data binding on WinForms. You can find details on this pattern here: http://aviadezra.blogspot.com/2009/08/mvp-mvvm-winforms-data-binding.html

MVVM (Model View View Model) introduces similar approach for separating the presentation from the data in an environment that empowers data binding (WPF). Since .NET framework 2.0 already offers advanced data binding infrastructure that also allows design time binding of application objects - the ‘View Model’ entity can fit quite well in MVP based environment.

Note that I borrowed this answer directly from a related question.

hemp
Thanks for the link, never would have found that one myself!
A: 

You might have a look at the WAF Windows Forms Adapter. It comes with the BookLibrary sample application that uses data binding in combination with the ORM Entity Framework.

jbe