To data-bind the DataGrid control to multiple tables in a dataset in the designer
Set the control's DataSource property to the object containing the data items you want to bind to.
If the dataset contains related tables (that is, if it contains a relation object), set the DataMember property to the name of the parent table.
Write code to fill the dataset.
To data-bind the DataGrid control programmatically
Write code to fill the dataset. For details, see Step 3 of the procedure "To data-bind the DataGrid control to a single table in the designer" above.
Call the DataGrid control's SetDataBinding method, passing it the data source and a data member. If you do not need to explicitly pass a data member, pass an empty string.
Note If you are binding the grid for the first time, you can set the control's DataSource and DataMember properties. However, you cannot reset these properties once they have been set. Therefore, it is recommended that you always use the SetDataBinding method.
The following example shows how you can programmatically bind to the Customers table in a dataset called DsCustomers1:
' Visual Basic
DataGrid1.SetDataBinding(DsCustomers1, "Customers")
// C#
DataGrid1.SetDataBinding(DsCustomers1, "Customers");
If the Customers table is the only table in the dataset, you could alternatively bind the grid this way:
' Visual Basic
DataGrid1.SetDataBinding(DsCustomers1, "")
// C#
DataGrid1.SetDataBinding(DsCustomers1, "");
(Optional) Add the appropriate table styles and column styles to the grid. If there are no table styles, you will see the table, but with minimal formatting and with all columns visible.