System.Windows.Forms.DataGrid.SetDataBinding Method

Sets the DataGrid.DataSource and DataGrid.DataMember properties at run time.

Syntax

public void SetDataBinding (object dataSource, string dataMember)

Parameters

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.

Remarks

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 ("").

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0