Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# resize datagridview columns to fit control

I have a datagridview that is docked and anchored with a panel on a Winform. When I resize the form, the datagridview resizes as expected, but the columns do not resize to fit the datagridview. Instead, I am left with the background colour of the Datagridview.

How can I get the columns to grow with the control?

Thanks.

like image 918
Darren Young Avatar asked Nov 16 '10 12:11

Darren Young


1 Answers

You could always use the AutoSizeColumnsMode property

This property lets you configure the control so that column widths are automatically adjusted either to fill the control or to fit cell contents. Size adjustments occur in fill mode whenever the width of the control changes.

There's a lot more information on the MSDN page for this.

like image 99
ChrisF Avatar answered Oct 11 '22 16:10

ChrisF