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...