Add a DataSet from the toolbox to your form. Using the Properties Window, add
a DataTable to the dataSet and add Columns to the DataTable. Or create your
own table at runtime:
dataTable1 = new DataTable("tabl ename");
dataTable1.Colu mns.Add("column 1", typeof(String)) ;
dataTable1.Colu mns.Add("column 2", typeof(String)) ;
dataTable1.Colu mns.Add("column 3", typeof(int));
To populate your DataTable:
DataRow dataRow = dataTable1.NewR ow();
dataRow[ "column 1" ] = "value 1";
dataRow[ "column 2" ] = "value 2";
dataRow[ "column 3" ] = 3;
dataTable1.Rows .Add(dataRow);
or
dataTable1.Rows .Add(new object[]{ "value 1", "value 2", 3 });
Finally, bind your DataTable to your DataGrid:
dataGrid1.SetDa taBinding(dataT able1, "");
Best Regards,
Phil.
"Wes" wrote:
I want to use a DataGrid and manually populate the data in the table. Does
anyone know how this is done?? I want to create all the Columns, and then
just add rows as my Program runs. Is there something else I should be using
in C# than a DataGrid.
Thanks for the Help