Export (0) Print
Expand All

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.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

'Declaration
Public Property FillWeight As Single

Property Value

Type: System.Single
A Single representing the width of the column when it is in fill mode relative to the widths of other fill-mode columns. The default is 100.

ExceptionCondition
ArgumentOutOfRangeException

The specified value when setting this property is less than or equal to 0.

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. All fill-mode columns in the control divide the available space in proportions determined by their FillWeight property values. For more information about column fill mode, see Column Fill Mode in the Windows Forms DataGridView Control.

The maximum sum of FillWeight values for all columns in a DataGridView control is 65535.

The following code example illustrates the use of this property. 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

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft