|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
BindingList: How to implement Find?Hi,
I have my own custom BindingList, that inherits from BindingList, and implements IComponent. I would like to implement a Find-method, that will allow me to search for a property of my Items. So basicly: If my Items in the List have a property Name, I would like to be able to return with this method all the items that have Name = 'Bill Gates' etc. Any idea how I should implement this? Any hints, links, samples would be really appreciated. Thanks a lot in advance, Pieter Hi,
you need the following:- Protected Overrides ReadOnly Property SupportsSearchingCore() As Boolean Get Return True End Get End Property then implement FindCore with your search hint: compare the PropertyDescriptor.GetValue with the property you are sorting against finally implement a GetItem (or similar) method something like:- Public Function GetItem(ByVal ColumnName As String, ByVal ColumnValue As Object) As T Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.Items(0).GetType) Dim myProperty As PropertyDescriptor = properties.Find(ColumnName, False) Dim i As Integer = FindCore(myProperty, ColumnValue) If i = -1 Then Return Nothing Else Return Me.Item(i) End If End Function Show quoteHide quote "Pieter" wrote: > Hi, > > I have my own custom BindingList, that inherits from BindingList, and > implements IComponent. > I would like to implement a Find-method, that will allow me to search for a > property of my Items. > > So basicly: If my Items in the List have a property Name, I would like to be > able to return with this method all the items that have Name = 'Bill Gates' > etc. > > Any idea how I should implement this? Any hints, links, samples would be > really appreciated. > > Thanks a lot in advance, > > Pieter > > >
object reference not set to an instance???
possible to create one control array with different controls? vb2005 propertybag After export to Excel, that excel cannot open Late binding equivalent Can you emulate an ActiveX exe in .NET "The path is not of a legal form" error - WinFoms designer dealing with images of varing sizes on a form. Field token out of range (System.BadImageFormatException) VB 'Phone Home' |
|||||||||||||||||||||||