Fit the Columns header into a DGV, C#

Asked

Viewed 33 times

1

Is there any way to fit the columns in a DMV so that not on the space (Follows the img as example). Or Resize the DGV to go back to the required size columns? at runtime.

inserir a descrição da imagem aqui

I’m using direct connection to DBso I don’t see the columnsprior to execution.

  • Try to change to false the property RowsHeaderVisible, thus: dataGridView1.RowsHeaderVisible = false;

  • @stderr as RowHeaderVisible are already in false .. the case would be to find some Autosize for Columnsheader to resize to DGV size.

1 answer

2


You solve this by accessing the property AutoSizeMode of each column. By default, the columns have AutoSizeMode = NotSet. You will need to define at least one column as AutoSizeMode = Fill together with the property FillWeight = 100.

Example:

this.dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
this.dataGridView1.Columns[1].FillWeight = 100;

Hug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.