DataGridViewColumn.FillWeight 屬性


取得或設定值,表示處於填入模式中的資料行寬度,相對於控制項中處於填入模式的資料行寬度。Gets or sets a value that represents the width of the column when it is in fill mode relative to the widths of other fill-mode columns in the control.

 property float FillWeight { float get(); void set(float value); };
public float FillWeight { get; set; }
member this.FillWeight : single with get, set
Public Property FillWeight As Single



Single,表示處於填入模式的資料行寬度,相對於其他填入模式資料行的寬度。A Single representing the width of the column when it is in fill mode relative to the widths of other fill-mode columns. 預設值為 100。The default is 100.


設定這個屬性時,指定的值小於或等於 0。The specified value when setting this property is less than or equal to 0.


下列程式碼範例說明如何使用此屬性。The following code example illustrates the use of this property. 這個範例是 如何:設定 Windows Forms DataGridView 控制項的調整大小模式時,所提供之較大範例的一部分。This example is part of a larger example available in How to: Set the Sizing Modes of the Windows Forms DataGridView Control.

dataGridView1.AutoSizeColumnsMode =

DataGridViewTextBoxColumn subTitleColumn =
    new DataGridViewTextBoxColumn();
subTitleColumn.HeaderText = "Subtitle";
subTitleColumn.MinimumWidth = 50;
subTitleColumn.FillWeight = 100;

DataGridViewTextBoxColumn summaryColumn =
    new DataGridViewTextBoxColumn();
summaryColumn.HeaderText = "Summary";
summaryColumn.MinimumWidth = 50;
summaryColumn.FillWeight = 200;

DataGridViewTextBoxColumn contentColumn =
    new DataGridViewTextBoxColumn();
contentColumn.HeaderText = "Content";
contentColumn.MinimumWidth = 50;
contentColumn.FillWeight = 300;
dataGridView1.AutoSizeColumnsMode = _

Dim subTitleColumn As new DataGridViewTextBoxColumn()
subTitleColumn.HeaderText = "Subtitle"
subTitleColumn.MinimumWidth = 50
subTitleColumn.FillWeight = 100

Dim summaryColumn As new DataGridViewTextBoxColumn()
summaryColumn.HeaderText = "Summary"
summaryColumn.MinimumWidth = 50
summaryColumn.FillWeight = 200

Dim contentColumn As new DataGridViewTextBoxColumn()
contentColumn.HeaderText = "Content"
contentColumn.MinimumWidth = 50
contentColumn.FillWeight = 300


InheritedAutoSizeMode 屬性值為時,資料行會隨著 Fill 該模式中的其他資料行調整大小,讓控制項中所有可見的資料行完全填滿可用顯示區域的水準寬度。When the InheritedAutoSizeMode property value is Fill, the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. 控制項中的所有填滿模式資料行都會以其屬性值所決定的比例來分割可用的空間 FillWeightAll fill-mode columns in the control divide the available space in proportions determined by their FillWeight property values. 如需資料行填滿模式的詳細資訊,請參閱 Windows Forms DataGridView 控制項中的資料行填滿模式For more information about column fill mode, see Column Fill Mode in the Windows Forms DataGridView Control.

FillWeight控制項中所有資料行的值總和上限 DataGridView 為65535。The maximum sum of FillWeight values for all columns in a DataGridView control is 65535.