IListSource IListSource IListSource IListSource Interface


データ ソースに連結できるリストを返す機能をオブジェクトに提供します。Provides functionality to an object to return a list that can be bound to a data source.

public interface class IListSource
[System.ComponentModel.TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public interface IListSource
type IListSource = interface
Public Interface IListSource

次のコード例は、実装する方法を示します、IListSourceインターフェイス。The following code example demonstrates how to implement the IListSource interface. という名前のコンポーネントEmployeeListSource公開、IList実装することで、データ バインド、GetListメソッド。A component named EmployeeListSource exposes an IList for data binding by implementing the GetList method. 完全なコード一覧については、次を参照してください。方法。IListSource インターフェイスを実装します。For a full code listing, see How to: Implement the IListSource Interface.

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace IListSourceCS
    public class EmployeeListSource : Component, IListSource
        public EmployeeListSource() {}

        public EmployeeListSource(IContainer container)

        #region IListSource Members

        bool IListSource.ContainsListCollection
            get { return false; }

        System.Collections.IList IListSource.GetList()
            BindingList<Employee>   ble = new BindingList<Employee>();

            if (!this.DesignMode)
                ble.Add(new Employee("Aaberg, Jesper", 26000000));
                ble.Add(new Employee("Cajhen, Janko", 19600000));
                ble.Add(new Employee("Furse, Kari", 19000000));
                ble.Add(new Employee("Langhorn, Carl", 16000000));
                ble.Add(new Employee("Todorov, Teodor", 15700000));
                ble.Add(new Employee("Verebélyi, Ágnes", 15700000));

            return ble;

Imports System.ComponentModel

Public Class EmployeeListSource
    Inherits Component
    Implements IListSource

    <System.Diagnostics.DebuggerNonUserCode()> _
Public Sub New(ByVal Container As System.ComponentModel.IContainer)

        'Required for Windows.Forms Class Composition Designer support

    End Sub

    <System.Diagnostics.DebuggerNonUserCode()> _
    Public Sub New()

        'This call is required by the Component Designer.

    End Sub

    'Component overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
        End If
    End Sub

    'Required by the Component Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Component Designer
    'It can be modified using the Component Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub

#Region "IListSource Members"

    Public ReadOnly Property ContainsListCollection() As Boolean Implements System.ComponentModel.IListSource.ContainsListCollection
            Return False
        End Get
    End Property

    Public Function GetList() As System.Collections.IList Implements System.ComponentModel.IListSource.GetList

        Dim ble As New BindingList(Of Employee)

        If Not Me.DesignMode Then
            ble.Add(New Employee("Aaberg, Jesper", 26000000))
            ble.Add(New Employee("Cajhen, Janko", 19600000))
            ble.Add(New Employee("Furse, Kari", 19000000))
            ble.Add(New Employee("Langhorn, Carl", 16000000))
            ble.Add(New Employee("Todorov, Teodor", 15700000))
            ble.Add(New Employee("Verebélyi, Ágnes", 15700000))
        End If

        Return ble

    End Function

#End Region

End Class


実装していないオブジェクトからのデータ ソースにバインドできるリストを返すこのインターフェイスを使用する通常IList自体。You typically use this interface to return a list that can be bound to a data source, from an object that does not implement IList itself.

いずれかの実行時に、または、デザイナーで、データへのバインドが発生することがそれぞれの規則があります。Binding to data can occur at either run time or in a designer, but there are rules for each. 実行時に、次のいずれかのデータにバインドできます。At run time, you can bind to data in any of the following:

  • Array

  • 実行者IList実装側がある厳密に型指定された、Item[Int32]プロパティ (つまり、Type以外はObject)。Implementer of IList, provided the implementer has a strongly typed Item[Int32] property (that is, the Type is anything but Object). これを実現するにはの既定の実装を行うをItem[Int32]プライベートです。You can accomplish this by making the default implementation of Item[Int32] private. 作成する場合、IList厳密に型指定されたコレクションの規則に従いますから派生する必要がありますCollectionBaseします。If you want to create an IList that follows the rules of a strongly typed collection, you should derive from CollectionBase.

  • 実行者ITypedListします。Implementer of ITypedList.

デザイナーへのバインドを初期化できますComponent同じ規則に従ってオブジェクト。In a designer, you can initialize binding to Component objects by following the same rules.


実装側IListSource返すことができます、IListのコレクションを格納しているIListオブジェクト。Implementers of IListSource can return an IList that contains a collection of IList objects.


ContainsListCollection ContainsListCollection ContainsListCollection ContainsListCollection

コレクションが IList オブジェクトのコレクションかどうかを示す値を取得します。Gets a value indicating whether the collection is a collection of IList objects.


GetList() GetList() GetList() GetList()

それ自体は IList を実装していないオブジェクトから、データ ソースに連結できる IList を返します。Returns an IList that can be bound to a data source from an object that does not implement an IList itself.