System.Windows.Forms.DataGridViewColumn.DisplayIndex Property

Gets or sets the display order of the column relative to the currently displayed columns.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public int DisplayIndex { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Unlike the DataGridViewBand.Index property, the DataGridViewColumn.DisplayIndex property corresponds to the current position of the column as displayed by the user interface (UI). By default, each column's DataGridViewColumn.DisplayIndex is set to numbers of increasing order, which reflects the order in which they were added. The DataGridViewColumn.Visible property value does not affect the DataGridViewColumn.DisplayIndex value. To determine the display position of a column based on its visibility or other state, use the erload:System.Windows.Forms.DataGridViewColumnCollection.GetFirstColumn, DataGridViewColumnCollection.GetLastColumn(DataGridViewElementStates, DataGridViewElementStates), or DataGridViewColumnCollection.GetNextColumn(DataGridViewColumn, DataGridViewElementStates, DataGridViewElementStates) method of the System.Windows.Forms.DataGridViewColumnCollection class.

Every column in the control has a unique DataGridViewColumn.DisplayIndex value. The values start with 0 and proceed in numerical order without skipping any values. When you change the DataGridViewColumn.DisplayIndex value for a column, the DataGridViewColumn.DisplayIndex values for other columns are changed to reflect the new order.

If the column has an associated System.Windows.Forms.DataGridView control, setting this property will cause the control to redraw itself.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0