ITypedList Interface
Assembly: System (in system.dll)
Use this interface if, for instance, you are using a DataView object that represents a customer table, you want to bind to the properties on the customer object that the DataView represents, not the properties of the DataView.
This interface is not required for design-time support of a bindable list.
Binding to data can occur either at run time or in a designer, but there are rules for both. At run time, you can bind to data in any of the following:
-
Implementer of IList, provided the implementer has a strongly typed Item property (that is, the Type is anything but Object). You can accomplish this by making the default implementation of Item private. If you want to create an IList that follows the rules of a strongly typed collection, you should derive from CollectionBase.
-
Implementer of ITypedList.
In a designer, you can initialize binding to Component objects by following the same rules.
For more information on binding to a data source, see the System.Windows.Forms.Binding class.
The following code example demonstrates how to implement the ITypedList interface. A generic type named SortableBindingList derives from the BindingList class and implements the ITypedList interface. For a full code listing, see How to: Implement the ITypedList Interface.
Imports System.ComponentModel Imports System.Collections.Generic Imports System.Windows.Forms <Serializable()> _ Public Class SortableBindingList(Of Tkey) Inherits BindingList(Of Tkey) Implements ITypedList <NonSerialized()> _ Private properties As PropertyDescriptorCollection Public Sub New() MyBase.New() ' Get the 'shape' of the list. ' Only get the public properties marked with Browsable = true. Dim pdc As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(Tkey), New Attribute() {New BrowsableAttribute(True)}) ' Sort the properties. properties = pdc.Sort() End Sub #Region "ITypedList Implementation" Public Function GetItemProperties(ByVal listAccessors() As System.ComponentModel.PropertyDescriptor) As System.ComponentModel.PropertyDescriptorCollection Implements System.ComponentModel.ITypedList.GetItemProperties Dim pdc As PropertyDescriptorCollection = Nothing If listAccessors Is Nothing Then ' Return properties in sort order pdc = properties Else ' Return child list shape pdc = ListBindingHelper.GetListItemProperties(listAccessors(0).PropertyType) End If Return pdc End Function ' This method is only used in the design-time framework ' and by the obsolete DataGrid control. Public Function GetListName( _ ByVal listAccessors() As PropertyDescriptor) As String _ Implements System.ComponentModel.ITypedList.GetListName Return GetType(Tkey).Name End Function #End Region End Class
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.