下列代码展示了如何使得在“Country”字段中包含“USA”值的行始终可视,而不考虑应用于视图的筛选。 接管了 ColumnView.CustomRowFilter 事件来控制行的可视性。
C# | 复制代码 |
---|
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;
if((string)dv[e.ListSourceRow]["Country"] == "USA") {
e.Visible = true;
e.Handled = true;
}
}
|
Visual Basic | 复制代码 |
---|
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
If CStr(dv(e.ListSourceRow)("Country")) = "USA" Then
e.Visible = True
e.Handled = True
End If
End Sub
|