DataTable DT = new DataTable();
DT.Columns.Add("编号");
DT.Columns.Add("管径");
DT.Columns.Add("速度");
DT.Columns.Add("和");
DT.Rows.Add(new string[] { "1", "1", "1","2"});
string[] no={"2","3","4","5"};
string[] diameter = { "1", "2", "3", "4" };
string[] speed = { "1", "1", "1", "1" };
List<string> sum = new List<string>();
for (int i = 0; i < diameter.Length; i++)
{
sum.Add((Convert.ToInt32(diameter[i]) + Convert.ToInt32(speed[i])).ToString());
DT.Rows.Add(no[i], diameter[i], speed[i], sum[i]);
}
this.dataGridView1.DataSource = DT;
text 真心不会做。 |