Sets the DataGrid.DataSource and DataGrid.DataMember properties at run time.
- dataSource
- The data source for the System.Windows.Forms.DataGrid control.
- dataMember
- The DataGrid.DataMember string that specifies the table to bind to within the object returned by the DataGrid.DataSource property.
You must use the DataGrid.SetDataBinding(object, string) method at run time to reset the DataGrid.DataSource property.
See the DataGrid.DataSource property for more details about setting a valid data source.
You can create a grid that enables users to edit data but prevents them from adding new rows by using a System.Data.DataView as the data source and setting the System.Data.DataView.AllowNew property to false. When the DataGrid.DataSource is a System.Data.DataView or System.Data.DataTable, set the DataGrid.DataMember to an empty string ("").