Skip to main content

Obtaining Fields Available in Data Source

  • 2 minutes to read

Data-aware controls (e.g., Grid Control and XtraTreeList) can be bound to various data sources (e.g., BindingList<T>, List<T>, IList and ITypedList). When bound to a data source, the control needs to determine fields (properties) available in the data source that can potentially provide data for columns. For instance, information on available fields allows for automatic column creation.

Information on the fields available in the data source is retrieved as follows.

  1. If the data source implements the ITypedList interface, this information is obtained using the methods of this interface.
  2. If the data source provides an indexer [], available properties in the data source match public properties provided by the indexer’s return type.
  3. If the data source derives from the List<T> type, available properties in the data source are those exposed by the generic type T.
  4. If the data source implements the IList interface, the first item is retrieved from the IList, and this item’s public properties will determine the properties available in the data source for a data-aware control.

    Note

    Information on the first item’s properties is retrieved only when assigning the data source to the data-aware control. Ensure that the data source contains at least one item of a target type prior to binding the data source to the control.