I have a DataGridView and I want only a specific column to resize when the window is resized.
Currently, I am resizing the columns which need to be fixed on form_Load() and form_Resize()
dataGrid1.Columns[0].Width = 100;
dataGrid1.Columns[1].Width = 100;
dataGrid1.Columns[3].Width = 100;
Is there a better way to do this?
There is an
AutoSizeModeproperty on theDataGridViewColumnclass.I’d imagine you want to set it to
DataGridViewAutoSizeColumnMode.AllCellson columns 0, 1 and 3, and to.Fillon column 2. (It looks like.Nonemeans it won’t even adjust to the cell contents, which I don’t think is what you want.)