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