I need my to fill my datagridview
with values from some list.
I try to make it in such way:
List<List<object>> objList1 = new List<List<object>>
{
new List<object> {null, null, null, "Some Value"},
new List<object> {"Some text", "Another Text", 212}
};
List<List<object>> objList2 = new List<List<object>>
{
new List<object> {null, null, null, "Some Value from 2 list"},
new List<object> {"Some text 3", "Another Text 5", 34}
};
foreach (var objList in objList1)
{
dataGridView.Rows.Add();
for (int i = 0; i < objList.Count -1; i++)
{
dataGridView.Rows[dataGridView.RowCount - 1].Cells[i].Value = objList[i] != null ? objList[i].ToString() : "";
}
}
dataGridView.Rows.Add();
foreach (var objList in objList2)
{
dataGridView.Rows.Add();
for (int i = 0; i < objList.Count - 1; i++)
{
dataGridView.Rows[dataGridView.RowCount - 1].Cells[i].Value = objList[i] != null ? objList[i].ToString() : "";
}
}
dataGridView.Rows.Add();
But instead of getting my datagridview
filled, I get only the last row filled: