Search code examples
c#winformsdatagridviewdatagridviewcolumn

Why is my DGV.MinimumWidth being ignored?


With this code:

const int COMMENTS_COLUMN_DESIRED_WIDTH = 412;
...
dgv.Columns[COMMENTS_COLUMN].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dgv.Columns[COMMENTS_COLUMN].MinimumWidth = COMMENTS_COLUMN_DESIRED_WIDTH;

...the COMMENTS column wraps, as I want it to, but after a width of maybe 120 pixels, nowhere near 412. Why is it wrapping before it hits its MinimumWidth value?

The data does not contain line breaks where the wrap is occurring.


Solution

  • I changed AutoSizeColumnsMode from "AllCells" to "None" and that does the trick.