Question : How to set datagridview height with number of rows given?

Hi,

I like to set the datagridview automatically from coding by giving number of rows.
The set datagridview height should not have a half row at the end of the rows.

Please help how to do it.

Thank you.

Answer : How to set datagridview height with number of rows given?

this should do it then
1:
2:
3:
4:
5:
Dim NumberOfRowsToShow As Integer = 10
 
Dim TotalHeight As Integer = (NumberOfRowsToShow * DataGridView1.RowTemplate.Height) + DataGridView1.ColumnHeadersHeight
 
DataGridView1.Height = TotalHeight
Random Solutions  
 
programming4us programming4us