Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
0 out of 2 rated this helpful - Rate this topic

IBindingList.Find Method

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

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

int Find (
	PropertyDescriptor property,
	Object key
)
int Find (
	PropertyDescriptor property, 
	Object key
)
function Find (
	property : PropertyDescriptor, 
	key : Object
) : int
Not applicable.

Parameters

property

The PropertyDescriptor to search on.

key

The value of the property parameter to search for.

Return Value

The index of the row that has the given PropertyDescriptor.
Exception typeCondition

NotSupportedException

SupportsSearching is false.

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


    }
  
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.