The properties for my UltraGrid show a property for what appears to be each of the ErrorProviders defined on the form. The description column is like "Error on ErrorProvider1" where ErrorProvider1 is replaced with the name of the provider. The property value is blank and when you click on it there are no defaults, dropdown or elipses provided. Is is possible to link the grid to an ErrorProvider and if so how?
Thanks, Dave
Hi Dave,
There is no such property on the grid. You are probably looking at an extender property. If you place an ErrorProvider component on your form, then the ErrorProvider component provides an extender property to any controls on the form. It's nothing to do specifically with the grid, this will show up on any control.
So then there isn't any way to use an ErrorProvider with an UltraGrid?
Hi,
Well, it depends on what you mean. An ErrorProvider component is intended to provide errors to a control. In this respect, the grid is no different than any other control.
I suspect, however, that you probably want to use the ErrorProvider to provide errors on the cell or row level, rather than to the whole grid. In that case, the answer is no, you can't use an ErrorProvider for this.
The grid does support the IDataErrorInfo interface, though. So you could display errors in the grid in a way very similar to the error provider, if you are using a data source that supports this interface, like a DataTable or DataSet. You just have to set UseDataErrorInfo to true. This property is on the Override object in the grid, I think.
I have implemented a grid whose data source is a business object, ie List<Customer>. This Customer class inherits from IDataErrorInfo. Everything works great, I can see the error icons in the individual cells.
My problem is I'm only validating at save time and I have lots of rows and bands. If there are many errors, it's difficult to visually find all the errors. I'd like to add a button that allows the user to go the next and previous error. Is there a programmatic way of going from one error to the next and putting the focus on the cell in error?
There's nothing built-in to the grid to navigate to errors. But I'm sure you could implement this yourself. You would have to loop through the cells individually. I'm not sure if the cell exposes a property that says whether or not there's an error there - I looked and couldn't find one, but maybe I missed it. If there isn't one, then what you could do is get the ListObject for the row and use that to determine which cells have errors.
I was a little worried about looping through the grid, but performance seems fine. Below is the code I used in case others are looking for a similar solution. As you can see, I stopped on just the row.
{
if ((int)c.CustomerID > errCustomerID) //make sure you're past the previous error
{ errCustomerID = (int)c.CustomerID;
}
{ CurrentRow.Activate(); }