'C# Datagridview method Rows.Add works incorrectly - it add line on previous, not on last

I have a problem with datagridview.Rows.Add method. I want to add a new line but in the last line, not in previous. I don't know why the method Add doesn't work in this case. My code:

        dataGridView1.RowCount = 3;
        dataGridView1.ColumnCount = 4;

        dataGridView1.Rows[0].Cells[0].Value = 1;
        dataGridView1.Rows[0].Cells[1].Value = 2;
        dataGridView1.Rows[0].Cells[2].Value = 3;
        dataGridView1.Rows[0].Cells[3].Value = 4;

        dataGridView1.Rows[1].Cells[0].Value = 5;
        dataGridView1.Rows[1].Cells[1].Value = 6;
        dataGridView1.Rows[1].Cells[2].Value = 7;
        dataGridView1.Rows[1].Cells[3].Value = 8;

        dataGridView1.Rows[2].Cells[0].Value = 9;
        dataGridView1.Rows[2].Cells[1].Value = 10;
        dataGridView1.Rows[2].Cells[2].Value = 11;
        dataGridView1.Rows[2].Cells[3].Value = 12;


        dataGridView1.Rows.Add(13,14,15,16);

And result:

enter image description here

I will be thrilled for any help or advice!



Solution 1:[1]

This is the correct way to insert a line in a grid view:

dataGridView1.Rows.Add(13,14,15,16);

The last line marked with * is in fact a placeholder for new lines and it is better not to insert it directly tempe place to make new row

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hadi