以编程方式添加行和列

时间:2012-10-25 09:44:56

标签: c# datagridview

dataGridView2.Columns[0].HeaderText = "Drive";
dataGridView2.Columns[0].DataPropertyName = root.ToString();
this.dataGridView2.Rows.Add(dataGridView2.Columns[0].DataPropertyName);

dataGridView2.Columns[1].HeaderText = "Volume Name";
dataGridView2.Columns[1].DataPropertyName = volumename.ToString();
this.dataGridView2.Rows.Add(dataGridView2.Columns[1].DataPropertyName);

dataGridView2.Columns[2].HeaderText = "Size";
dataGridView2.Columns[2].DataPropertyName = size.ToString();
dataGridView2.Rows.Add(dataGridView2.Columns[2].DataPropertyName);

我无法在列[1]和[2]中添加行,因为它在列[0]索引中添加。

0 个答案:

没有答案