IListSource.GetList 方法

定義

從本身沒有實作 IList 的物件傳回可以繫結至資料來源的 IList

C#
public System.Collections.IList GetList ();

傳回

IList,從物件繫結至資料來源。

範例

下列程式代碼範例示範如何實作 IListSource 介面。 名為 EmployeeListSource 的元件會 IList 藉由實作 方法來公開資料系結的 GetList 。 如需完整的程式代碼清單,請參閱 如何:實作 IListSource 介面

C#
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;
}

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

另請參閱