DataGrid.PreferredColumnWidth 属性

定义

获取或设置网格列的默认宽度(以像素为单位)。Gets or sets the default width of the grid columns in pixels.

public:
 property int PreferredColumnWidth { int get(); void set(int value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.DataGridPreferredColumnWidthTypeConverter))]
public int PreferredColumnWidth { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.DataGridPreferredColumnWidthTypeConverter))>]
member this.PreferredColumnWidth : int with get, set
Public Property PreferredColumnWidth As Integer

属性值

Int32

网格中列的默认宽度(以像素为单位)。The default width (in pixels) of columns in the grid.

属性

例外

属性值小于 0。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
   

注解

在重置和属性之前设置此属性 DataSource DataMember (单独或通过 SetDataBinding 方法) ,否则属性将不起作用。Set this property before resetting the DataSource and DataMember properties (either separately, or through the SetDataBinding method), or the property will have no effect.

不能将属性设置为小于0的值。The property cannot be set to a value less than 0.

适用于

另请参阅