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 display the white table only.
Any suggestions ?
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 display the white table only.
Any suggestions ?
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.
Set the RowsHeaderVisible
property to false, you can either do that from the designer, in category Appearence
, or from the code :
dataGridView1.RowsHeaderVisible = false;
In order to remove the indicator row on the left side, as for the rest of the grey space, you can try set the aforementionned AutoSizeColumnsMode
to Fill, but you will still have the lower part grayed out from lack of rows.
Instead of sizing your cells to fill your grid, you could resize your grid in order to fit around your cells. Whether or not this is an acceptable approach will depend on your intent.
I mean, it's possible that if its just the color that is bothering you, setting the backcolor to white would do the trick.
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;