Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

indexing - 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

**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();
        }
question from:https://stackoverflow.com/questions/65949455/message-index-was-out-of-range-must-be-non-negative-and-less-than-the-size-of

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...