**Message : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
here is my code **
try { // int row = Convert.ToInt32(dataGridView1.DataKeys[e.RowIndex].Value); int curRow = dataGridView1.CurrentRow.Index; myFun.valueSelected1 = dataGridView1.Rows[curRow].Cells[0].Value.ToString(); myFun.valueSelected2 = dataGridView1.Rows[curRow].Cells[1].Value.ToString(); myFun.valueSelected3 = dataGridView1.Rows[curRow].Cells[2].Value.ToString(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error !!"); new Exceptionwrite.MessageWriteToFile(ex).WriteToFile(); //new MessageWriteToFile(d).WriteToFile(); }
2.1m questions
2.1m answers
60 comments
56.9k users