Wednesday, April 27, 2011

UltraWinGrid default (active) row selection and bad exception handling

I have a UltraWinGrid bound to a BindingSource object data source .   This is how I display list of rows in the grid.

The only difference between the two methods is, last line in the second method, This is an classic bad example exceptions.

By default, UltraWinGrid selects a row if no row is selected, I was trying to disable this behavior, I couldn't find any straight property or method to do this. I found ActiveRow  returning the selected row and it has a setter. So I thought setting ActiveRow to null would disable the selection. But it doesn't. I have couple of problems with this line,

ultraWinListGrid.ActiveRow = null;
  1. It doesn't do what it looks like doing
  2. It doesn't tell me what happened and why it didn't do it.
  3. It doesn't prevent me doing things it can’t do.

So, How did I solve this, that's an another poor encapsulation story. Take a look here for a workaround.