Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Grid cell Error Indicator not showing immediately
posted

I have the UltraGrid (v 9.1) bound to a BindingList<T>.  My binding list has also implemented INotifyPropertyChanged - it will pass any property changes gathered from the contained items up and out of the collection.  The bound item implements IDataErrorInfo and INotifyPropertyChanged.  

I validate the collection when a button is pressed.  When the button is pressed, I walk the collection (not the grid), setting the properties that are in error as being "property changed" with the property name and then set its error string (returned by IDataErrorInfo).  Therefore the grid should know each and every row that is modified and the exact cell/property that gets modified.

This all works great with one exception.  Not all of my error indicators will show up _immediately_.  The ones that are in error and do not repaint properly seem to show up when the cell is queried by the grid again.  Specifically, I can have two rows in error (each with two cells).  The first row will have its error indicator show up in the first cell as it should.  The second row's error indicator will not show up in the first cell until which time I move the mouse over the second row.  This tells me that the grid is not fully querying the collection to find out each and every row in error.

What have I missed or put another way how can I work around this issue?  Grid.Invalidate() will not work as that would be too easy <grin>.

 

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    the IBindingList interface, as far as I know, does not have any way to send a notification when the error state on a row or cell changes. I think the idea is that the error conditions are based on the value of a cell and so te IDataErrorInfo should return an error when the notification that the data has changed is sent.

    In other words, wen you change the value of a cell and you call INotifyPropertyChanged, the BindingList traps this notification and sends a notification that some values in the row have changed. It is this notification that the grid is looking for and this tells the grid to repaint the cell. If, at the time of receiving this notification, the IDataErrorInfo doesn't return an error, then the grid can't display the error unless it somehow gets refreshed again.

    So basically, it seems like validating the data in a button click is really not the intended use of IDataErrorInfo.

    DSSavant said:
    I validate the collection when a button is pressed.  When the button is pressed, I walk the collection (not the grid), setting the properties that are in error as being "property changed" with the property name and then set its error string (returned by IDataErrorInfo).  Therefore the grid should know each and every row that is modified and the exact cell/property that gets modified.

    If what you are writing here is correct and you are calling INotifyPropertyChanged when the button is clicked and the error occurs, then theoretically, you would just need to make sure that the IDataErrorInfo is applied BEFORE you send the notification.

    If that's not working, then it's probably something we would need to look into in more detail. In which case, we would need a small sample project demonstrating this.

    DSSavant said:
    What have I missed or put another way how can I work around this issue?  Grid.Invalidate() will not work as that would be too easy <grin>.

    If you want to try to work around this, I recommend that you try calling grid.Rows.Refresh(ReloadData) and see if that helps. You would call this after you have set all your errors, of course.

Children