如何在特定的行索引之后过滤高级数据网格视图?

问题描述 投票:0回答:1

我有一个高级数据网格视图,即NameTable。在高级Datagrid视图中使用过滤器选项时,前两行不应进行过滤或排序。过滤器选项应仅在第二行之后适用。`公开课表格1公共DtTable作为数据表私有SBind作为BindingSource = New BindingSource()私有子Form1_Load(作为对象发送,作为EventArgs发送)处理MyBase.Load

    DtTable = New DataTable
    With DtTable
        .Columns.Add(" Name", GetType(String))
        .Columns.Add("Age" + vbLf + " (kg/hr)", GetType(String))
        .Columns.Add("Subject ", GetType(String))
        .Columns.Add(" Marks")
    End With
    Dim dr As DataRow
    For i = 0 To 1
        dr = DtTable.NewRow()
        dr(0) = vbNullString
        dr(1) = vbNullString
        Select Case i
            Case 0
                dr(2) = "Maths"
            Case 1
                dr(2) = "Science "
        End Select
        DtTable.Rows.Add(dr)
    Next
    dr = DtTable.NewRow()
    dr(0) = "Mark"
    dr(1) = "18"
    dr(2) = vbNullString
    dr(3) = "98"
    DtTable.Rows.Add(dr)

    dr = DtTable.NewRow()
    dr(0) = "Rachel"
    dr(1) = "18"
    dr(2) = vbNullString
    dr(3) = "60"
    DtTable.Rows.Add(dr)

    SBind.DataSource = DtTable
    DataGridView1.DataSource = SBind

End Sub

私有子IPFSourceADGV_SortStringChanged(发送方为对象,e作为EventArgs)处理IPFSourceADGV.SortStringChanged

    Me.SBind.Sort = Me.IPFSourceADGV.SortString
End Sub
 Private Sub datagridview1_SortStringChanged(sender As Object, e As EventArgs) Handles datagridview1.SortStringChanged

    Me.SBind.Sort = Me.datagridview1.SortString
End Sub

Private Sub datagridview1_FilterStringChanged(sender As Object, e As EventArgs) Handles datagridview1.FilterStringChanged
    Me.SBind.Filter = Me.datagridview1.FilterString
End Sub

结束班级`SampleTable

这只是过滤整个表。

c# vb.net windows-forms-designer
1个回答
0
投票
Dim DtTable As DataTable = New DataTable

With DtTable
    .Columns.Add(" Name", GetType(String))
    .Columns.Add("Age" + vbLf + " (kg/hr)", GetType(String))
    .Columns.Add("Subject ", GetType(String))
    .Columns.Add(" Marks")
End With

For Each row As DataRow In DtTable.Rows
    If DtTable.Rows.Count <> 0 Then
        If DtTable.Rows.IndexOf(row) > 2 Then
            ' filter
        End If
    End If
Next

我不知道我是否正确理解...

这样,您可以在表格的第二行之后工作。告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.