private datatable dt = new DataTable ();
BindingSource bs = new BindingSource ();
<summary>
Initializing a DataTable
</summary>
public void initdatatable ()
{
Do not allow automatic generation, if allowed, the interface will automatically increase the DataTable column, then the interface will contain the columns defined in the DataGridView, also contains the DataTable defined columns
This.dataGridView1.AutoGenerateColumns = false;
DataColumn col = new DataColumn ("No", typeof (int));
Dt. Columns.Add (COL);
Dt. Columns.Add (New DataColumn ("Addr", typeof (String)));
Dt. Columns.Add (New DataColumn ("Funtiontype", typeof (String)));
Dt. Columns.Add (New DataColumn ("Result", typeof (String)));
Bs. DataSource = DT;
This.dataGridView1.DataSource = BS;
Data-binding columns in DataGridView to columns in a DataTable, this.clonum as column names
This.colNum.DataPropertyName = "No";
This.colAddress.DataPropertyName = "Addr";
This.colFunction.DataPropertyName = "Funtiontype";
This.colResult.DataPropertyName = "Result";
}
Create a DataTable to bind to DataGridView