Hello, I'm trying to pass a variable from main form to child form. The code below is giving me error:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
VB.NET Code:
list = new List<string>(); DataGridViewRow row = programs_dgv.Rows[programs_dgv.CurrentRow.Index]; using (InsertData insertData = new InsertData()) { list[0] = row.Cells[2].Value.ToString(); list[1] = row.Cells[3].Value.ToString(); list[2] = row.Cells[4].Value.ToString(); list[3] = row.Cells[5].Value.ToString(); list[4] = row.Cells[6].Value.ToString(); list[5] = row.Cells[7].Value.ToString(); list[6] = row.Cells[8].Value.ToString(); list[7] = row.Cells[9].Value.ToString(); list[8] = row.Cells[10].Value.ToString(); list[9] = row.Cells[11].Value.ToString(); list[10] = row.Cells[12].Value.ToString(); list[11] = row.Cells[13].Value.ToString(); list[12] = row.Cells[14].Value.ToString(); insertData._list = list; insertData.ShowDialog(); list = insertData.GetValues(); if (insertData.cancelRequested == true) { return; } }