0

我正在为 datagridview 开发高级搜索和过滤器控件。我放了一些代码来搜索整个数据网格列和任何值,但它给出了一些错误:

Public ReadOnly Property Count As Integer' has no parameters and its return type cannot be indexed

代码 :

Private Sub _filters_CollectionChanged(ByVal sender As Object, ByVal e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
        'Indicates whether the collection really changed
        Dim changed As Boolean = True

        'If a new element is added
        If e.Action = System.Collections.Specialized.NotifyCollectionChangedAction.Add Then
            For Each fi As FilterItem In e.NewItems

                'If the collection already contains this FilterItem

 '***********************************************************************************
                If _filters.Count((Function(x) x.Equals(fi))) > 1 Then 'Error Line here
 '************************************************************************************
                    SyncLock syncroot
                        'Disable the eventhandler while removing the item
                        RemoveHandler _filters.CollectionChanged, AddressOf _filters_CollectionChanged
                        'Remove the newly added FilterItem from the collection
                        _filters.RemoveAt(e.NewItems.IndexOf(fi))
                        'Enable the eventhandler
                        AddHandler _filters.CollectionChanged, AddressOf _filters_CollectionChanged
                        'The collection actually didn't change, there's no need to refilter
                        changed = False
                    End SyncLock
                Else
                    'subscribe to its event, so filtering will be done automatically every time when the filter changes
                    AddHandler fi.FilterChanged, AddressOf Filter
                End If
            Next
            'If the filter is removed
        ElseIf e.Action = System.Collections.Specialized.NotifyCollectionChangedAction.Remove Then
            For Each fi As FilterItem In e.OldItems
                'unsubscribe from its event
                RemoveHandler fi.FilterChanged, AddressOf Filter
            Next
        End If

        'Finally filter the list
        If changed Then
            Filter()
        End If
    End Sub
4

0 回答 0