Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User can't resize DataGridView columns

I have a DataGridView with the datasource set to a binding source of data. My problem is I cannot get most of the columns to resize. Several of the columns don't show a resize cursor, while two others do: one can be resized, one cannot.

Here is what I have tried:

  • DGV.AllowUsertoResizeColumns = True
  • DGV.AutoSizeColumnMode = None
  • DGV.RowHeadersWidthSizeMode = EnableResizing
  • DGV.Dock = Fill
  • All Columns having AutoSizeMode = NoneSet and Resizable = True
  • The DGV is embedded in a panel of a SplitContainer, yet after bringing it to front, the others to back, or other random combinations, still unable to resize
  • Using dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader) (and other variations) after data has been loaded into the DGV
  • While I'm able to resize one of the columns, the settings in the Columns collection are no different from the others

Here's a screenshot of the properties of my DataGridView:

DataGridView Properties

Any Ideas?

like image 963
Paul Avatar asked Jul 16 '13 15:07

Paul


People also ask

How do I resize a DataGridView control when resized?

Users can make size adjustments by dragging or double-clicking row, column, or header dividers. In column fill mode, column widths change when the control width changes; for example, when the control is docked to its parent form and the user resizes the form.

How set DataGridView size in C#?

Set the DataGridView. AutoSizeColumnsMode property to Fill to set the sizing mode for all columns that do not override this value. Set the FillWeight properties of the columns to values that are proportional to their average content widths.

What is DataGridView in C#?

The DataGridView control provides a customizable table for displaying data. The DataGridView class allows customization of cells, rows, columns, and borders through the use of properties such as DefaultCellStyle, ColumnHeadersDefaultCellStyle, CellBorderStyle, and GridColor.


2 Answers

Upon checking the individual column settings in the gridview, I found some cells still had

AutoSizeMode = AllCells

I changed this to:

AutoSizeMode = NotSet

and now I am able to resize all columns.

like image 178
Paul Avatar answered Jan 04 '23 10:01

Paul


Set:

AutoSizeColumnsMode = none

enter image description here

like image 36
HiSura Avatar answered Jan 04 '23 10:01

HiSura