DataGridViewBand.Index Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the relative position of the band within the DataGridView control.

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

[<BrowsableAttribute(false)>]
member Index : int with get

Property Value

Type: System.Int32

The zero-based position of the band in the DataGridViewRowCollection or DataGridViewColumnCollection that it is contained within. The default is -1, indicating that there is no associated DataGridView control.

The value of this property does not necessarily correspond to the current visual position of the band within the collection. For example, if the user reorders columns in a DataGridView at run time (assuming the AllowUserToOrderColumns property is set to true), the value of the Index property of each column will not change. Instead, the column DisplayIndex values change. Sorting rows, however, does change their Index values.

The following code example uses the Index property to set column labels. The band's Index property is accessed through a DataGridViewColumn.

System_CAPS_noteNote

If visual styles are enabled, the current theme overrides the display style properties for row and column headers.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: