Welcome to

Magenic Technologies Community Blog

Sign in | Join | Help

Aaron's Technology Musings

Who let this guy on the podium?

BindingSource and Infragristics Ultragrid - Non obvious adventures in binding

Ok - a little hint.  Should you ever want to bind a collection (i.e. something that inherits from List<foo> ) - to a grid, you would think all you need to do is:

bindingSource.DataSource = _someCollection;

Apparently, if you are binding to the Infragristics Ultragrid (at least before the latest hotfix) - it is not that simple.  You could do the above, but the datasource changed event will bubble up through the grid and, as a nice side effect, remove all the formatting you set up, forcing you to either write code that resets all the formatting you did in the designer, or... this little hack:

bindingSource.Clear();
if (_someCollection != null)
  foreach(SomeObject obj in _someCollection)
    bindingSource.Add(obj);

Apparently, BindingSource allows direct access to the list methods, but not to the core list itself (well, of course, other than through replacing the datasource which causes the aforementioned event to bubble).

It all goes to show that the “magic” that you can accomplish with binding does not, and probably will never, make your job truly easier.  There will always be leaky abstractions that make your life interesting.

Also, Infragristics needs to change its name to something easier to pronounce and spell. ;)  Just a suggestion...

Published Tuesday, October 17, 2006 9:25 PM by aarone

Comments

No Comments

New Comments to this post are disabled
Powered by Community Server, by Telligent Systems