The DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:
For specific examples, see the Example section and the task table at the end of this section.
Typically, you will bind to a BindingSource component and bind the BindingSource component to another data source or populate it with business objects. The BindingSource component is the preferred data source because it can bind to a wide variety of data sources and can resolve many data binding issues automatically.
When binding to a data source that contains multiple lists or tables, you must set the DataMember property to a string that specifies the list or table to bind to. When binding to a BindingSource component that contains multiple lists or tables, however, you can set the DataMember property of the BindingSource component instead.
When binding to an object collection rather than to database data, you will typically set the DataSourceNullValue property of the object returned by the DefaultCellStyle property to nullNothingnullptra null reference (Nothing in Visual Basic) rather than using the default value of DBNull..::.Value, which is appropriate for database data.
For more information, see Displaying Data in the Windows Forms DataGridView Control. The following table provides direct links to common tasks related to the DataSource property.