views:

207

answers:

3

Or do you populate your form controls manually by a method?

Is either considered a best practice?

+1  A: 

Hey Keith,

Well, it depends. I have tended to use databinding wherever I could - it is darn convenient, but on occasion, I'll populate them manually. Particularly, I find it useful with controls like the DataGridView to use databinding. It makes filtering quite simple.

itsmatt
+1  A: 

It really depends from what you are trying to achieve.

Databinding is simple and powerful, but if you need more control or some kind of side effect, you can manually populate control from a method.

Personally, I start with a databinding first, than change it later if it is necessary.

Nenad
+1  A: 

Generally, if data binding business or DAL objects is possible, I would use it. The old axiom holds true: The most error-free and reliable line of code is often the one you didn't have to write. (Bear in mind, however, that you need to know exactly how that data binding occurs, what its overhead is, and you have to be able to trust the framework and your source objects to be error-free!)

You would, as others have mentioned, manually populate if you needed specific functionality not brought to bear directly by binding, or if there is an issue with data binding business/DAL objects (as occasionally happens with certain 3rd-party controls).

John Rudy