DataGrid.PreferredColumnWidth Property


Gets or sets the default width of the grid columns in pixels.

 property int PreferredColumnWidth { int get(); void set(int value); };
public int PreferredColumnWidth { get; set; }
member this.PreferredColumnWidth : int with get, set
Public Property PreferredColumnWidth As Integer

Property Value

The default width (in pixels) of columns in the grid.



The property value is 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


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.

Applies to

See also