2
votes

I have 2 columns in my data grid view. But these 2 columns occupy only a portion of the view. How do i make both columns fill the view completely such first columns takes 50% space and second column takes the rest

3

3 Answers

4
votes

Use

this.MyColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
this.MyColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

Then play with property this.MyColumn2.FillWeight for your purpose...

1
votes

In visual studio in the properties window, when you select the dataGridView go to the property AutoSizeColumnsMode and select the option Fill. All the columns will fit all the place of the dataGridView.

0
votes

Change the column width to fill e.g.

oColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

If you do this for all columns they will equally fill the grid (with or without the scrollbars). If you only sent if for 1 column that column will fill the remaining space leftover after all columns have been sized