DataGridViewColumn.Width Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the current width of the column.
public:
property int Width { int get(); void set(int value); };
public int Width { get; set; }
member this.Width : int with get, set
Public Property Width As Integer
The width, in pixels, of the column. The default is 100.
The specified value when setting this property is greater than 65536.
The following code example sets the width of a column. This code example is part of a larger example provided for the DataGridViewColumn class.
// Set the width.
void Button5_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
DataGridViewColumn^ column = dataGridView->Columns[ 0 ];
column->Width = 60;
}
// Set the width.
private void Button5_Click(object sender, System.EventArgs e)
{
DataGridViewColumn column = dataGridView.Columns[0];
column.Width = 60;
}
' Set the width.
Private Sub Button5_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button5.Click
Dim column As DataGridViewColumn = dataGridView.Columns(0)
column.Width = 60
End Sub
If the specified value when setting this property is less than the value of the MinimumWidth property, the MinimumWidth property value is used instead.
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, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: