Using an ErrorProvider with an UltraGrid?

This post has 11 Replies | 6 Followers

dspicer
Points 275
Replied On: Thu, Jan 3 2008 5:23 PM

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

  • Post Points: 20
Mike Saltzman
Points 466,155
Infragistics Employee
Replied On: Fri, Jan 4 2008 9:38 AM

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.  

Mike Saltzman

Manager - Windows Forms Development

Infragistics, Inc.

  • Post Points: 20
dspicer
Points 275
Replied On: Fri, Jan 4 2008 10:13 AM

So then there isn't any way to use an ErrorProvider with an UltraGrid?

Thanks, Dave

  • Post Points: 20
Mike Saltzman
Points 466,155
Infragistics Employee
Replied On: Mon, Jan 7 2008 10:15 AM

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.

Mike Saltzman

Manager - Windows Forms Development

Infragistics, Inc.

  • Post Points: 35
dspicer
Points 275
Replied On: Thu, Jan 10 2008 9:54 AM

Mike,

Thanks for the info. The property to set is SupportDataErrorInfo and it is in the Override object.

Dave

  • Post Points: 5
brentnations
Points 180
Replied On: Tue, Mar 4 2008 10:54 AM

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?

 

  

  • Post Points: 35
Mike Saltzman
Points 466,155
Infragistics Employee
Replied On: Wed, Mar 5 2008 11:45 AM

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. 

Mike Saltzman

Manager - Windows Forms Development

Infragistics, Inc.

  • Post Points: 20
brentnations
Points 180
Replied On: Wed, Mar 5 2008 12:10 PM

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.  

foreach (Customer c in Customers)

{

     IDataErrorInfo customerStatus = c as IDataErrorInfo;    if (customerStatus.Error != "")

     {

          if ((int)c.CustomerID > errCustomerID) //make sure you're past the previous error

              {      errCustomerID = (int)c.CustomerID; 

                     changed = true;                     break;

              }

      }

}

if (changed)

{

      foreach (UltraGridRow CurrentRow in grdCustomers.Rows.GetAllNonGroupByRows())

     {

           if ((int)CurrentRow.Cells["CustomerID"].Value == errCustomerID)

                { CurrentRow.Activate(); }

     }

}

 

  • Post Points: 5
Ashish
Points 519
Replied On: Fri, Mar 26 2010 5:21 AM

Hello,
I am facing a very similar situation, which you faced some time ago.

I have a  grid whose data source is a business entity, ie BidingList<Person>. I want to validate user inputs for all cells in the row(s) for that grid.
I want to use the approach listed at http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WinGrid_Display_Row_Cell_Errors_Using_IDataErrorInfo.html but the issue is that in my case the e.Row.ListObject returns a BidingList<Person>. , whereas the example in this link expects a DataRowView .

How did you resolve it in ur case, as you also had a business entity and not a DataRowView .

Pls advice.

Is there any other better approach for it ? using fragistics UltraValidator control, custom coding for cellupdate events, etc.

  • Post Points: 20
cobaia
Points 317
Replied On: Fri, Sep 24 2010 2:14 PM

If the grid  data source is bound to a  business entity, ie BindingList<Person>, then wouldn't e.Row.ListObject simply return an entity instance of Person?

  • Post Points: 20
TobiasV
Points 295
Replied On: Tue, Apr 9 2013 8:57 AM

My problem exactly, sample code fails on following line:

            var drv = (DataRowView)e.Row.ListObject;

Have you solved this? And how?

  • Post Points: 20
Mike Saltzman
Points 466,155
Infragistics Employee
Replied On: Wed, Apr 10 2013 9:46 AM

Hi Tobias,

The ListObject returns the object in the data source that represents the data item. The problem with the code you have here is that it is assuming that the object is always a DataRowView. That will only be true if you are using a DataSet / DataTable as your DataSource. If you are using a List<T> or a BindingList<T>, then you can't cast that into a DataRowView, because it's not a DataRowView, it's a T.

So if your data source is: BindingList<Person>

Then your code to get the typed ListObject would be:

var drv = (Person)e.Row.ListObject;

Mike Saltzman

Manager - Windows Forms Development

Infragistics, Inc.

  • Post Points: 5
Page 1 of 1 (12 items) | RSS