DataGridViewColumn.FillWeight DataGridViewColumn.FillWeight DataGridViewColumn.FillWeight DataGridViewColumn.FillWeight Property

定義

取得或設定值,表示處於填入模式中的資料行寬度,相對於控制項中處於填入模式的資料行寬度。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.

public:
 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 =
    DataGridViewAutoSizeColumnsMode.Fill;

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 = _
    DataGridViewAutoSizeColumnsMode.Fill

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

備註

當屬性值為Fill時,資料行會隨著該模式中的其他資料行調整大小,讓控制項中所有可見的資料行完全填滿可用顯示區域的水準寬度。 InheritedAutoSizeModeWhen 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. 控制項中的所有填滿模式資料行都會以其FillWeight屬性值所決定的比例來分割可用空間。All 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資料行值的最大總和為65535。 DataGridViewThe maximum sum of FillWeight values for all columns in a DataGridView control is 65535.

適用於

另請參閱