IBindingList.Find(PropertyDescriptor, Object) IBindingList.Find(PropertyDescriptor, Object) IBindingList.Find(PropertyDescriptor, Object) IBindingList.Find(PropertyDescriptor, Object) Method

Definición

Devuelve el índice de la fila que tiene el PropertyDescriptor especificado.Returns the index of the row that has the given PropertyDescriptor.

public:
 int Find(System::ComponentModel::PropertyDescriptor ^ property, System::Object ^ key);
public int Find (System.ComponentModel.PropertyDescriptor property, object key);
abstract member Find : System.ComponentModel.PropertyDescriptor * obj -> int
Public Function Find (property As PropertyDescriptor, key As Object) As Integer

Parámetros

key
Object Object Object Object

Valor del parámetro property que se va a buscar.The value of the property parameter to search for.

Devoluciones

Índice de la fila que tiene el PropertyDescriptor especificado.The index of the row that has the given PropertyDescriptor.

Excepciones

Ejemplos

En el ejemplo de código siguiente se muestra cómo Find implementar el método.The following code example demonstrates how to implement the Find method.

    public class MyFontList : BindingList<Font>
    {

        protected override bool SupportsSearchingCore
        {
            get { return true; }
        }
        protected override int FindCore(PropertyDescriptor prop, object key)
        {
            // Ignore the prop value and search by family name.
            for (int i = 0; i < Count; ++i)
            {
                if (Items[i].FontFamily.Name.ToLower() == ((string)key).ToLower())
                    return i;

            }
            return -1;
        }


    }
  
}
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

Comentarios

Este método seleccionará la primera fila en la que el valor property del parámetro es igual al valor key del parámetro.This method will select the first row where the value of the property parameter equals the value of the key parameter.

Se admite este método si SupportsSearching es true, de lo contrario, este método NotSupportedExceptionproduce una excepción.This method is supported if SupportsSearching is true, otherwise this method throws a NotSupportedException.

Se aplica a