I was wondering whether it is possible to remove the unused space ( the gray space ) of the DataGridView
control in C#. I have to make the DataGridView
I use this code for and it works for my if you don't add a button column or image I take it from a site but I don't remember from where :
For Each row As DataGridViewRow In DataGridView1.Rows
If datagrid_limits > newHeight Then
newHeight =newHeight + 40
Else
Exit For
End If
Next
DataGridView1.Height = newHeight
I believe you want:
myDataGrid.AutoSizeColumnsMode = Fill
EDIT: This just resizes the columns. I'm not sure how you would get rid of row gray space other than resizing the grid's height.