DataGrid::PreferredColumnWidth Property
.NET Framework (current version)
Gets or sets the default width of the grid columns in pixels.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [TypeConverterAttribute((DataGridPreferredColumnWidthTypeConverter^::typeid))] property int PreferredColumnWidth { int get(); void set(int value); }
| Exception | Condition |
|---|---|
| ArgumentException | The property value is less than 0. |
Set this property before resetting the DataSource and DataMember properties (either separately, or through the SetDataBinding method), or the property will have no effect.
The property cannot be set to a value less than 0.
The following code example sets the default column widths to a value passed to the method.
Private Sub SetDefaultColWidth(defColWidth As Integer) DataGrid1.PreferredColumnWidth = defColWidth End Sub
.NET Framework
Available since 1.1
Available since 1.1
Show: