我有一個有dataGridView並將其值傳遞給文本框的表單,但當我單擊任何列時,我總是收到ArgumentOutOfRangeException
。DataGridView越來越ArgumentOutOfRangeException
如果只有行被點擊,這些代碼工作正常。
private void dataGridProd_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = this.dataGridProd.Rows[e.RowIndex];
foreach (DataGridViewColumn column in dataGridProd.Columns)
{
column.SortMode = DataGridViewColumnSortMode.NotSortable;
txBName.Text = row.Cells[1].Value.ToString();
txBPrice.Text = row.Cells[2].Value.ToString();
}
btnAdd.Enabled = true;
prodQuanUpDown.Enabled = true;
}
任何類型的響應非常感謝。先謝謝你!
異常發生在哪一行? – Ben
關於productName和productPrice – vicserna1997
row.Cells數組中有多少項? – KiwiPiet