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,这些视图与 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. 由于数据源仅支持一个视图, 因此该方法返回一个元素的集合, 该集合使用视图的默认名称。Because the data source supports only one view, the method returns a collection of one element using the default name for the view. 此代码示例是为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

注解

数据源控件类可支持其基础数据的一个或多个命名视图。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 GetView使用方法检索单个对象。Callers can iterate through the collection of view names and retrieve individual DataSourceView objects with the GetView method.

实现IDataSource接口的数据源控件类GetViewNames实现方法以返回名称的集合, 这些名称表示当前与数据源控件类相关联的所有数据源视图对象。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.

适用于

另请参阅