下列代码展示了如何使得在“Country”字段中包含“USA”值的行始终可视,而不考虑应用于视图的筛选。 接管了 ColumnView.CustomRowFilter 事件来控制行的可视性。

C#CopyCode image复制代码
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;

private void gridView1_CustomRowFilter(object sender, RowFilterEventArgs e) {
   GridView view = sender as GridView;
   DataView dv = view.DataSource as DataView;
   // Check whether the current row contains "USA" in the "Country" field.
   if((string)dv[e.ListSourceRow]["Country"] == "USA") {
      // Make the current row visible.
      e.Visible = true;
      // Prevent default processing, so the row will be visible 
      // regardless of the view's filter.
      e.Handled = true;
   }
}
Visual BasicCopyCode image复制代码
Imports DevExpress.XtraGrid.Views.Grid

Private Sub GridView1_CustomRowFilter(ByVal sender As Object, _
  ByVal e As DevExpress.XtraGrid.Views.Base.RowFilterEventArgs) _
  Handles GridView1.CustomRowFilter
   Dim view As GridView = CType(sender, GridView)
   Dim dv As DataView = view.DataSource
   ' Check whether the current row contains "USA" in the "Country" field.
   If CStr(dv(e.ListSourceRow)("Country")) = "USA" Then
      ' Make the current row visible.
      e.Visible = True
      ' Prevent default processing, so the row will be visible 
      ' regardless of the view's filter.
      e.Handled = True
   End If
End Sub