DataSourceControl.GetViewNames DataSourceControl.GetViewNames DataSourceControl.GetViewNames DataSourceControl.GetViewNames Method

定義

取得名稱集合,表示與 DataSourceView 控制項關聯的 DataSourceControl 物件清單。Gets a collection of names, representing the list of DataSourceView objects associated with the DataSourceControl control.

protected:
 virtual System::Collections::ICollection ^ GetViewNames();
protected virtual System.Collections.ICollection GetViewNames ();
abstract member GetViewNames : unit -> System.Collections.ICollection
override this.GetViewNames : unit -> System.Collections.ICollection
Protected Overridable Function GetViewNames () As ICollection

傳回

ICollection,包含與 DataSourceView 關聯的 DataSourceControl 物件名稱。An ICollection that contains the names of the DataSourceView objects associated with the DataSourceControl.

實作

範例

下列程式碼範例示範擴充DataSourceControl類別的類別如何覆寫傳回的預設實null值, 以提供視圖名稱的集合。The following code example demonstrates how a class that extends the DataSourceControl class can override the default implementation, which returns null, to provide a collection of view names. CsvDataSource類別僅支援一個視圖, 因此會傳回一個具有預設 view 名稱的元素集合。The CsvDataSource class only supports one view; therefore, a collection of one element with the default view name is returned. 這個程式碼範例是針對DataSourceControl類別提供之較大範例的一部分。This 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

備註

名稱集合是一組可傳遞GetView至方法的允許值。 ICollectionThe ICollection collection of names is the allowable set of values that can be passed to the GetView method.

DataSourceControl 類別(GetViewNames用於類別的IListSource 執行)IListSource.GetList會檢查和呼叫的方法, 以判斷資料來源控制項是否與一個關聯IListSource.ContainsListCollection ListSourceHelper或更多資料來源 views。The ListSourceHelper class, which is used for the DataSourceControl class's IListSource implementation, checks the GetViewNames method for both the IListSource.ContainsListCollection and IListSource.GetList calls to determine whether the data source control is associated with one or more data source views. GetViewNames IListSource.ContainsListCollection false IListSource.GetList 如果傳回null(這是方法的預設執行), 則會傳回, 並傳回。 nullIf GetViewNames returns null, which is the default implementation of the method, IListSource.ContainsListCollection returns false and IListSource.GetList returns null.

注意

類別的預設null實值會傳回。 DataSourceControlThe DataSourceControl class's default implementation returns null. 如果您擴充DataSourceControl類別, 請覆GetViewNames寫方法以傳回視圖名稱的集合。If you extend the DataSourceControl class, override the GetViewNames method to return a collection of view names.

適用於

另請參閱