Results 1 to 4 of 4

Thread: How to implement the IBindingListView

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Huntsville, AL
    Posts
    62

    How to implement the IBindingListView

    Hello,

    I have a custom object that I would like to turn into a Collection that could then be used in a BindingSource. From what I've read, I can Inherit Collection(Of T) where T is my specific object. Then I can Implement IBindingListView. This is all great, but I have no idea how to actually use the IBindingListView Interface. I know I want to be able to sort and filter my collection, so I have the following.

    Code:
    Imports System.ComponentModel
    
    Public Class ChemicalCollection
        Inherits Collections.ObjectModel.Collection(Of Chemical)
    
        Implements IBindingListView
    
        Public Sub AddIndex(ByVal [property] As PropertyDescriptor) Implements IBindingList.AddIndex
    
        End Sub
    
        Public Function AddNew() As Object Implements IBindingList.AddNew
    
        End Function
    
        Public ReadOnly Property AllowEdit() As Boolean Implements IBindingList.AllowEdit
            Get
    
            End Get
        End Property
    
        Public ReadOnly Property AllowNew() As Boolean Implements IBindingList.AllowNew
            Get
    
            End Get
        End Property
    
        Public ReadOnly Property AllowRemove() As Boolean Implements IBindingList.AllowRemove
            Get
    
            End Get
        End Property
    
        Public Sub ApplySort(ByVal [property] As PropertyDescriptor, ByVal direction As ListSortDirection) Implements IBindingList.ApplySort
    
        End Sub
    
        Public Function Find(ByVal [property] As PropertyDescriptor, ByVal key As Object) As Integer Implements IBindingList.Find
    
        End Function
    
        Private _IsSorted As Boolean
        Public ReadOnly Property IsSorted() As Boolean Implements IBindingList.IsSorted
            Get
                Return _IsSorted
            End Get
        End Property
    
        Public Event ListChanged(ByVal sender As Object, ByVal e As ListChangedEventArgs) Implements IBindingList.ListChanged
    
        Public Sub RemoveIndex(ByVal [property] As PropertyDescriptor) Implements IBindingList.RemoveIndex
    
        End Sub
    
        Public Sub RemoveSort() Implements IBindingList.RemoveSort
    
        End Sub
    
        Public ReadOnly Property SortDirection() As ListSortDirection Implements IBindingList.SortDirection
            Get
    
            End Get
        End Property
    
        Public ReadOnly Property SortProperty() As PropertyDescriptor Implements IBindingList.SortProperty
            Get
    
            End Get
        End Property
    
        Public ReadOnly Property SupportsChangeNotification() As Boolean Implements IBindingList.SupportsChangeNotification
            Get
                Return True
            End Get
        End Property
    
        Public ReadOnly Property SupportsSearching() As Boolean Implements IBindingList.SupportsSearching
            Get
                Return True
            End Get
        End Property
    
        Public ReadOnly Property SupportsSorting() As Boolean Implements IBindingList.SupportsSorting
            Get
                Return True
            End Get
        End Property
    
        Public Sub ApplySort1(ByVal sorts As ListSortDescriptionCollection) Implements IBindingListView.ApplySort
    
        End Sub
    
        Private _Filter As String
        Private _IsFiltered As Boolean
        Public Property Filter() As String Implements IBindingListView.Filter
            Get
                Return _Filter
            End Get
            Set(ByVal value As String)
                _Filter = value
                _IsFiltered = (value.Length <> 0)
            End Set
        End Property
    
        Public Sub RemoveFilter() Implements IBindingListView.RemoveFilter
            Me.Filter = ""
        End Sub
    
        Public ReadOnly Property SortDescriptions() As ListSortDescriptionCollection Implements IBindingListView.SortDescriptions
            Get
    
            End Get
        End Property
    
        Public ReadOnly Property SupportsAdvancedSorting() As Boolean Implements IBindingListView.SupportsAdvancedSorting
            Get
                Return True
            End Get
        End Property
    
        Public ReadOnly Property SupportsFiltering() As Boolean Implements IBindingListView.SupportsFiltering
            Get
                Return True
            End Get
        End Property
    End Class
    As you can see, I haven't really done anything other than let Visual Studio fill in the required properties and methods when I implemented the interface.

  2. #2
    Addicted Member
    Join Date
    Nov 2010
    Location
    TamilNadu, India
    Posts
    249

    Re: How to implement the IBindingListView


  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Huntsville, AL
    Posts
    62

    Re: How to implement the IBindingListView

    I tried that example, and unless I'm missing something (which is certainly possible), the first method doesn't use the IBindingListView interface, it uses delegates. The other example has the line of code "Implements IBindingListView", but doesn't use any of it's properties or methods, causing errors.

    Is it too complicated to explain how to implement the IBindingListView interface?

  4. #4
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    429

    Re: How to implement the IBindingListView

    am also expecting some insights in it. can anyone please explain?
    Never Give UP! It is Mindset that brings you success!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width