IBindingList.Find Method

Returns the index of the row that has the given PropertyDescriptor.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

'Declaration
Function Find ( _
	property As PropertyDescriptor, _
	key As Object _
) As Integer

Parameters

property
Type: System.ComponentModel.PropertyDescriptor

The PropertyDescriptor to search on.

key
Type: System.Object

The value of the property parameter to search for.

Return Value

Type: System.Int32
The index of the row that has the given PropertyDescriptor.

This method will select the first row where the value of the property parameter equals the value of the key parameter.

This method is supported if SupportsSearching is true, otherwise this method throws a NotSupportedException.

The following code example demonstrates how to implement the Find method.

Public Class MyFontList
    Inherits BindingList(Of Font)

    Protected Overrides ReadOnly Property SupportsSearchingCore() As Boolean 
        Get 
            Return True 
        End Get 
    End Property 

    Protected Overrides Function FindCore(ByVal prop As PropertyDescriptor, _
        ByVal key As Object) As Integer 
        ' Ignore the prop value and search by family name. 
        Dim i As Integer 
        While i < Count
            If Items(i).FontFamily.Name.ToLower() = CStr(key).ToLower() Then 
                Return i
            End If
            i += 1
        End While 

        Return -1
    End Function 
End Class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft