-
Oct 19th, 2011, 10:16 AM
#1
Thread Starter
Member
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.
-
Oct 19th, 2011, 10:55 AM
#2
Addicted Member
Re: How to implement the IBindingListView
-
Oct 19th, 2011, 03:56 PM
#3
Thread Starter
Member
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?
-
Jun 8th, 2015, 03:01 PM
#4
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|