I'm using a UltraGrid that is bound to a object data source. The objects in the datasource implement IDataErrorInfo and when an object has an error it shows up in the grid cell and that all works fine.
However, the grid also has some unbound columns. When the value of one of the cells in an unbound column is invalid (it's negative for example) I would like the grid to detect it make the cell to look the same as a cell in a bould column in an error state.
The grid is using a style file.
Hi,
So as I understand it, the problem is that.... since you are using a custom object data source, you cannot add new columns to it at run-time, since there's no way to add a new property to the class. Is that right?
There are a couple of ways you could handle this.
One way would be to use a DataTable, instead of your custom objects. Obviously, that's not a great solution since it means you have to copy the data from your objects into a DataTable and vice versa.
So if that's no good, you could take a more advanced approach and implement ITypedList on your object collection. This would allow you to determine the list of property descriptors that your list returns to the DotNet BindingManager and you could add in some extra ones as you choose. Your objects would then have to store the data somewhere, of course, perhaps in an array or a List.
You will also need to send the property IBindingList notifications when you add/remove a field.
This is pretty advanced stuff, but it is certainly possible to achieve.
Hi Marianne,
No we still don't have a good solution. We using app styling which is what revealed this limitation (i.e. why do those cells with negative numbers look different than the other ones?). Since the unbound columns are added dymically at run time I can't think of a good way to add them to the business object that binds to the grid. One way would be to add a bunch of dummy columns and hiding them, then unhide one each time the user wishes to "create" a new column. But that approach sets an artificial limit on the number of new columns. The new column names and values are stored to a different table so I thought about doing some linq query that would join both tables and bind that to the grid, but that approach means that every time a new column is added the grid would need to be re-bound.
I submitted a feature request, but it didn't return a tracking number. Any ideas or help would be most appreciated.
cobaia said:Maybe what I'm looking for is Grid.DisplayLayout.Override.DataErrorCellAppearance.
I don't beleive that will work. This will only return any information that you actually set on it. It will not account for the default appearance of error cells/rows, nor will it account for Application Styling.
If you are not using Application Styling, then you could, of course, look at a cell and hard-code the defaults. I'm pretty sure the defaults is just to use an image.
Wondering if you have any questions that I can help you with. Were you able to implement the work around that Mike suggested?
In your conversation with Mike, you mentioned that you “submitted a feature request”. I was wondering if I could help you with that. It sounds as if you would like support for showing data errors in unbound columns.
Hold up. Maybe what I'm looking for is Grid.DisplayLayout.Override.DataErrorCellAppearance.