Back to Devexpress

Obtaining Fields Available in Data Source

windowsforms-15737-common-features-data-binding-obtaining-fields-available-in-data-source.md

latest1.2 KB
Original Source

Obtaining Fields Available in Data Source

  • Jan 23, 2019
  • 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.