DatagridView: Remove unused space?

前端 未结 8 1126
-上瘾入骨i
-上瘾入骨i 2021-01-11 15:25

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

相关标签:
8条回答
  • 2021-01-11 16:08

    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
    
    0 讨论(0)
  • 2021-01-11 16:14

    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.

    0 讨论(0)
提交回复
热议问题