我在页面加载事件中动态地在 datagridview 中添加数据。但我收到一个错误,指出索引超出范围。(“必须为非负数且小于 datagridview 中 collection.parameter 名称的大小。”)
以下是代码:
dataGridView1.Rows.Add();
dataGridView1.Rows[0].Cells[0].Value = "Basic";
dataGridView1.Rows[0].Cells[1].Value = "Basic";
dataGridView1.Rows[1].Cells[0].Value = "PDALLW";
dataGridView1.Rows[1].Cells[1].Value = "Professional Development Allow";
dataGridView1.Rows[2].Cells[0].Value = "BPAllw";
dataGridView1.Rows[2].Cells[1].Value = "Business Promotion Allowance";