2
我想將指定的數據添加到列中,但出現錯誤「索引超出範圍必須是非負數並小於集合的大小 參數名稱:索引「如何將指定的數據添加到datagridview中的列
private void Button1Click(object sender, EventArgs e)
{
var result = _transactionService.GetTransactionReport(DateTime.Now.AddDays(-2), DateTime.Now);
foreach (var transaction in result)
{
for (int r = 0; r < result.Count; r++)
{
dataGridView1.Rows[r].Cells[0].Value = transaction.Number;
dataGridView1.Rows[r].Cells[1].Value = transaction.DateTime;
dataGridView1.Rows[r].Cells[1].Value = transaction.Customer.Name;
}
}
}
如何將數據添加到行和列?
謝謝你的作品! :d – yovierayz