DataGridViewColumn.MinimumWidth Property

Definition

Gets or sets the minimum width, in pixels, of the column.

public int MinimumWidth { get; set; }

Property Value

The number of pixels, from 2 to Int32.MaxValue, that specifies the minimum width of the column. The default is 5.

Exceptions

The value is less than 2 or greater than Int32.MaxValue.

Examples

The following code example sets the minimum width of a column. This code example is part of a larger example provided for the DataGridViewColumn class.

//Set the minimum width.
private void Button4_Click(object sender,
    System.EventArgs e)
{
    DataGridViewColumn column = dataGridView.Columns[1];
    column.MinimumWidth = 40;
}

Remarks

The MinimumWidth property sets a limit on how narrow the column can be resized in the user interface (UI). The Width property can override the MinimumWidth property.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also