Row Height
Consider the following example for adding rows after setting the row template height:
Result:
Note that in addition to using:
we also needed:
Taking out “.AllowUserToAddRows = false”:
It seems as though the last row in a Data Grid View is seen as a “new” row when “.AllowUserToAddRows” is “true”; a “new” row in the sense that it is a row that the user is still in the process of adding. Even if we programmatically put data in the row with “dgv.Rows[0].Cells[0].Value”, it is still a new row until the user clicks into it and makes a change to it. (This seems to be true even if “ReadOnly” is set to “true”.) And then “Rows.Add()” adds rows after the last row in the table that is not a new row. Putting “AllowUserToAddRows = false” makes it so that the user cannot add a new row and a row added by “Rows.Add()” is added at the end. I couldn’t find anything futher about this behavior in the Microsoft documentation for Add or DataGridView. This StackOverflow answer has more information and does mention the Microsoft documentation for the DataGridView’s NewRowIndex property.
(Just to note, as far as the above example goes, we can remove “dgv.ReadOnly = true;” and it works the same.)