469,619 Members | 1,963 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,619 developers. It's quick & easy.

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
Feb 24 '06 #1
1 8704
guy
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

"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

Feb 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by TG | last post: by
1 post views Thread by Pieter | last post: by
6 posts views Thread by jwilson128 | last post: by
10 posts views Thread by Rick | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.