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 窗体 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 窗体 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.

适用于

另请参阅