Search code examples
c#winformsdatagridview

How to calculate DataGridView.Rows.Height?


How to calculate dgv.Rows.Height

int x = dgv1.Rows.Height  

Rows.Height or dgv1.RowsHeight does not exists.


Solution

  • Row heights can vary, so try the row you want:

    int x = dgv1.Rows[0].Height;
    

    Alternatively, I think it's also available from the template:

    int x = dgv1.RowTemplate.Height;