Im developing programs in C# winforms, and also have gone lower the road of databinding my grids utilizing a bindingsource. My real question is:

Is a great way to consider? Must i by hand populate cells rather than letting the binding source get it done for me personally? Could it result in problems further lower the track?

If there any any situations where databinding would create issues that might be helpful.

Among my co-workers swears black and blue not to use databinding. I dont really trust what he states, so any pros/cons could be valuable.

EDIT: Within the situation of the multi-user programs hooking up to some single database and editable datagrids, how does one solve concurrency issues for upgrading of information?


Promising black and blue about anything without giving explanations why is, frankly, dumb.

You will find situations where data-binding is excellent, and situations where it's more trouble than worth. Your friend is not doing you any favors if perhaps confirming in the "discomfort" finish from the spectrum.

For straightforward display of information, great! It'll help you save time and effort and errors. For direct updates of information (including property logic and IDataErrorInfo support), again, great!. And even it's a core a part of WPF etc.

You will find situations where it is not so useful:

  • massive data volumes (where "virtual" mode helps, or better: don't display ten million rows it is not useful to anybody)
  • if you do not want the updates to become direct, but instead: deferred - although binding to some view-model (instead of your domain-model) is a great counter argument to that particular
  • if you have many different threads attempting to bind towards the same data (again, independent view-models help here)

I'd request your friend "why" and when they cannot give a very good reason, I'd be inclined to disregard them. With no sensible discussion behind it is only FUD.

I dont see not a problem with BindingSource component. Only suggestion isn't to make use of Untyped datasets. Use BindingList with classes as well as your ready.

BindingSource is certainly much better than traditional databinding.

Read about BindingSource Component Architecture.

One quite simple example:

With Databindings its quite simple to change data from database into something helpful. For eg you've got a decimal column in database with means currency amount:

With databindings it is simple to display it as being a currency:

private void DecimalToCurrencyString(object sender, ConvertEventArgs cevent)
   // The method converts only to string type. Test this using the DesiredType.
   if(cevent.DesiredType != typeof(string)) return;

   // Use the ToString method to format the value as currency ("c").
   cevent.Value = ((decimal) cevent.Value).ToString("c");

private void CurrencyStringToDecimal(object sender, ConvertEventArgs cevent)
   // The method converts back to decimal type only. 
   if(cevent.DesiredType != typeof(decimal)) return;

   // Converts the string back to decimal using the static Parse method.
   cevent.Value = Decimal.Parse(cevent.Value.ToString(),
   NumberStyles.Currency, null);

private void BindControl()
   // Creates the binding first. The OrderAmount is a Decimal type.
   Binding b = new Binding
      ("Text", ds, "customers.custToOrders.OrderAmount");
   // Add the delegates to the event.
   b.Format += new ConvertEventHandler(DecimalToCurrencyString);
   b.Parse += new ConvertEventHandler(CurrencyStringToDecimal);

Source Link