Version

Filtering Rows with Errors

WinGrid™ supports filtering based on whether cells have errors as determined by the IDataErrorInfo implementation of the underlying data source. The FilterOperandDropDownItems property of the UltraGridColumn and Override objects provides a way to select which items should be displayed in the filter drop down list that exists in the filter row or header icons. This property consists of the following flagged options:

All, Blanks, CellValues, Custom, Default, Errors, NonBlanks, NonErrors, ShowAll, ShowNone.

The following code is placed in the WinGrid control’s InitializeRow event in order to set data errors. The FilterOperandDropDownItems property is configured to list the “Errors” filter option in the drop down list, which when it is selected by the end user, it displays all rows whose cell values match the error condition.

This topic assumes that you have an UltraGrid control dropped onto your form and bound to the Orders table of the Northwind Database.

In Visual Basic:

Imports System.Data.SqlClient
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
...
Me.ultraGrid1.DisplayLayout.Override.SupportDataErrorInfo = SupportDataErrorInfo.RowsAndCells
Me.ultraGrid1.DisplayLayout.Override.FilterUIType = FilterUIType.HeaderIcons
Me.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.[True]
Dim rowError As String = ""
Dim cellError As String = ""
Dim value As [Object] = e.Row.Cells("ShippedDate").Value
' Set the data error if ShippedDate column is empty
If DBNull.Value = value Then
    rowError = "Row contains errors"
    cellError = "Shipped Date can not be empty"
End If
Dim drv As DataRowView = DirectCast(e.Row.ListObject, DataRowView)
drv.Row.RowError = rowError
drv.Row.SetColumnError("ShippedDate", cellError)
' Lists only the "Errors" filter option in the Filter drop down list
Me.ultraGrid1.DisplayLayout.Override.FilterOperandDropDownItems = FilterOperandDropDownItems.Errors

In C#:

using System.Data.SqlClient;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
...
this.ultraGrid1.DisplayLayout.Override.SupportDataErrorInfo = SupportDataErrorInfo.RowsAndCells;
this.ultraGrid1.DisplayLayout.Override.FilterUIType = FilterUIType.HeaderIcons;
this.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;
string rowError = "";
string cellError = "";
Object value = e.Row.Cells["ShippedDate"].Value;
// Set the data error if ShippedDate column is empty
if (DBNull.Value == value)
{
  rowError = "Row contains errors";
  cellError = "Shipped Date can not be empty";
}
DataRowView drv = (DataRowView)e.Row.ListObject;
drv.Row.RowError = rowError;
drv.Row.SetColumnError("ShippedDate", cellError);
// Lists only the "Errors" filter option in the Filter drop down list
this.ultraGrid1.DisplayLayout.Override.FilterOperandDropDownItems = FilterOperandDropDownItems.Errors;

WinGrid displaying Rows that match the error condition.

WinGrid Filtering Rows with Errrors.png