Hi,
I am using an UltraWinGrid which is binded with an object that inherit the ITypedList and IBindingList interface. This object contains a PropertyDescriptorCollection where each PropertyDescriptor represents a column of the grid.
The display and the basic edition of each cells works fine.
But, I would like to add the capability to set a cell in error if, for example, the value is out of bounds. Note that even if the value is out of bounds, the value is set in the data side and the user can continue to edit the cell. In this case I just want to set a different back color for the cell and put a warning icon.
I found some posts talking about the IDataErrorInfo interface. I fully understand the part describing how to customize the error displaying, but I need some help on how to set a cell in error state on the binding side.
Does my binding object have to implement the IDataErrorInfo ? or maybe each PropertyDescriptor objects created by the binding object ? And then how to say concretely that a cell is in error.
Thanks
Jean-Charles Durand
The IDataErrorInfo would be implemented on whatever object represents a row in the grid. So the items returned by your ITypedList would be the place to implement it.
Hi Mike,
Thanks for your response concerning the implementation of the IDataErrorInfo.
But, you agree that the two methods of this interface will be called when a cell is in error ?
And in my case, I have to set a cell in error after applying the new value in the binding side, that it's correspond to the call of the SetValue method of the PropertyDescriptor class. And in this case, I don't know how to say to the grid one cell is in error.
I hope you will understand my need.
Best regards,
Jean-Charles Durand said:But, you agree that the two methods of this interface will be called when a cell is in error ?
I'm not sure exactly what you mean. When the grid row is displayed, the grid will check to see if the ListObject for the row implemented IDataErrorInfo and if so, it will examine the interface to see if the row/cell should display an error. Assuming you turned SupportsDataErrorInfo on in the grid.
Setting a value on the data source should be sending a notification to the grid (or any bound control) via the IBindingList interface. If your IBindingList implementation is correct, then the grid cell should refresh to show the new data and any errors that exist at that time.
Hi mike,
Thanks again for the reply !
It's ok for me now, I fully understand how it works :)
i have just to make some enhancement in the way to display the error.
So what is the easiest way to change the error icon in the cell ?
best regards.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Override.DataErrorCellAppearance.Image = myImage; }
Thanks for your support Mike.
Best regards.