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.
There's no support for showing data errors in unbound columns.You could display an image in the cell, of course, using the cell's Appearance.
Or you could add the fields you need to your data object.
Either way, I recommend that you Submit a feature request to Infragistics
Thanks for your quick response Mike. I submitted a feature request.
One of the features of our app is to have a dialog that lets the user insert unbound columns into a bound grid at run time. This makes it difficult to have corresponding columns in the data object. Also, the data in the unbound columns is saved to a different table than the table the grid is bound to.
Do you know where the IDataErrorInfo appearace definition is for the grid so I can take that appearance and apply it to the unbound grid cell's appearance in the grid's AfterCellUpdate event?
It looks like Mike gave you a couple of ideas of how to achieve what you would like to do. Is there anything more I can help you with?
I ended up creating a custom collection that is derived from the generic BindingList and ITypeList as Mike suggested. The entity objects are added to the custom collection which is then bound to the ultragrid. When a new column is added, DataBind is called on the grid which, in turn, makes the ultragrid call TypedList.GetItemProperties on the custom collection. A new descriptor for the column is added to the returned PropertyDescriptorCollection. The new column appears in the grid like magic.
It was a more complicated solution than I initially wanted to pursue, but this solution eliminated all the event code in the control's code-behind page and, most important, the columns behave like the other column in the grid including showing the IDataErrorInfo glyph and tooltip.
Thanks your help and support.
Hi,
I might be wrong, but I don't think you have to call DataBind on the grid. A better way to do this would be to have your DataSource send an IBindingList.ListChanged notification any time you add or remove a column. There is a notification specifically for this.
Right again Mike. DataBind works, but I noticed it forces a call to the grid's InitializeLayout. Don't know how to send a ListChanged notification, but added a method to the custom collection class to call the BindingList's OnListChanged method with the new property descriptor. Seems to do it.
Thanks x2!
cobaia said:Don't know how to send a ListChanged notification, but added a method to the custom collection class to call the BindingList's OnListChanged method with the new property descriptor.
That's how you do it. :)