System.Windows.Forms.DataGrid.DataMember Property

Gets or sets the specific list in a DataGrid.DataSource for which the System.Windows.Forms.DataGrid control displays a grid.

Syntax

[System.ComponentModel.Editor("System.Windows.Forms.Design.DataMemberListEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultValue(null)]
public string DataMember { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

If a DataGrid.DataSource contains multiple sources of data, you should set the DataGrid.DataMember to one of the sources. For example, if the DataGrid.DataSource is a System.Data.DataSet or System.Data.DataViewManager that contains three tables named Customers, Orders, and OrderDetails, you must specify one of the tables to bind to. If the System.Data.DataSet or System.Data.DataViewManager contains only one System.Data.DataTable, you should set the DataGrid.DataMember to the System.Data.DataTable.TableName of that System.Data.DataTable.

If the DataGrid.DataSource is set to a System.Data.DataSet that contains System.Data.DataRelation objects, parent tables will appear with a plus sign (+) in each row header. Clicking the plus sign causes a node to appear that contains links to child tables. For example, if a System.Data.DataSet contains two System.Data.DataTable objects named Customers and Orders, setting the DataGrid.DataMember to the Customers table causes the System.Windows.Forms.DataGrid to display a parent table with a plus sign visible on each row header. If the DataGrid.DataMember is set to Orders, however, the row headers will be blank.

If the DataGrid.DataSource is a System.Data.DataTable, System.Data.DataView, collection, or array, setting the DataGrid.DataMember property throws an exception.

Note:

At run time, you must use the DataGrid.SetDataBinding(object, string) method to reset the DataGrid.DataSource property. However, the DataGrid.DataMember property alone can be reset at any time to a valid table name.

Requirements

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