IDataSource.GetViewNames 方法

定義

取得名稱集合,表示與 IDataSource 介面關聯的檢視物件清單。Gets a collection of names representing the list of view objects associated with the IDataSource interface.

public:
 System::Collections::ICollection ^ GetViewNames();
public System.Collections.ICollection GetViewNames ();
abstract member GetViewNames : unit -> System.Collections.ICollection
Public Function GetViewNames () As ICollection

傳回

ICollection

ICollection,包含與 IDataSource 關聯的檢視名稱。An ICollection that contains the names of the views associated with the IDataSource.

範例

下列程式碼範例將示範如何執行介面的資料來源控制項 IDataSource ,以傳回 GetViewNames ICollection 名稱的集合。The following code example demonstrates how a data source control that implements the IDataSource interface implements the GetViewNames method, returning an ICollection collection of names. 因為資料來源只支援一個 view,所以此方法會使用視圖的預設名稱傳回一個元素的集合。Because the data source supports only one view, the method returns a collection of one element using the default name for the view. 這個程式碼範例是針對類別提供之較大範例的一部分 DataSourceControlThis code example is part of a larger example provided for the DataSourceControl class.

    // The ListSourceHelper class calls GetList, which
    // calls the DataSourceControl.GetViewNames method.
    // Override the original implementation to return
    // a collection of one element, the default view name.
    protected override ICollection GetViewNames() {
        ArrayList al = new ArrayList(1);
        al.Add(CsvDataSourceView.DefaultViewName);
        return al as ICollection;
    }
}
   ' The ListSourceHelper class calls GetList, which
   ' calls the DataSourceControl.GetViewNames method.
   ' Override the original implementation to return
   ' a collection of one element, the default view name.
   Protected Overrides Function GetViewNames() As ICollection
      Dim al As New ArrayList(1)
      al.Add(CsvDataSourceView.DefaultViewName)
      Return CType(al, ICollection)
   End Function 'GetViewNames

End Class

備註

資料來源控制項類別可支援其基礎資料上的一個或多個命名視圖。Data source control classes can support one or more named views on their underlying data. 方法會傳回 GetViewNames 目前與資料來源控制項實例相關聯之視圖名稱的集合。The GetViewNames method returns a collection of view names currently associated with the data source control instance. 呼叫端可以逐一查看視圖名稱的集合,並使用方法來取出個別的 DataSourceView 物件 GetViewCallers can iterate through the collection of view names and retrieve individual DataSourceView objects with the GetView method.

實介面的資料來源控制項類別會 IDataSource 執行 GetViewNames 方法,以傳回名稱集合,這些名稱表示目前與資料來源控制項類別相關聯的所有資料來源 view 物件。Data source control classes that implement the IDataSource interface implement the GetViewNames method to return a collection of names that represents all the data source view objects currently associated with the data source control class.

適用於

另請參閱