Ish Goel
Ish Goel

Reputation: 315

Adjusting column width according to Screen Size in DataGridView (WinForms)

I have achieved the following till now (Columns are NOT resizing automatically as per the size of the application):

Static Column Widths

I want to achieve the following so that columns resize dynamically whenever user changes the size of the application:

Dynamic Column Widths

I am using DataGridView in .Net 2008

Upvotes: 2

Views: 4759

Answers (1)

Grant Winney
Grant Winney

Reputation: 66509

Specify a value for DataGridViewAutoSizeColumnsMode:

dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

You can set it in the grid properties at design-time too:

enter image description here

Upvotes: 4

Related Questions