Gets or sets the display order of the column relative to the currently displayed columns.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
DataGridViewElement.DataGridView is not null and the specified value when setting this property is less than 0 or greater than or equal to the number of columns in the control.
DataGridViewElement.DataGridView is null and the specified value when setting this property is less than -1.
The specified value when setting this property is equal to Int32.MaxValue.
Unlike the Index property, the property corresponds to the current position of the column as displayed by the user interface (UI). By default, each column's is set to numbers of increasing order, which reflects the order in which they were added. The Visible property value does not affect the value. To determine the display position of a column based on its visibility or other state, use the GetFirstColumn, GetLastColumn, or GetNextColumn method of the DataGridViewColumnCollection class.
Every column in the control has a uniquevalue. The values start with 0 and proceed in numerical order without skipping any values. When you change the value for a column, the values for other columns are changed to reflect the new order.
If the column has an associated DataGridView control, setting this property will cause the control to redraw itself.
The following code example uses the DataGridViewColumn class.property to swap the visual position of the first and last columns. Note that insertions occur before the . This code example is part of a larger example provided for the
Available since 2.0