DataGridColumn.DisplayIndex Property

Definition

Gets or sets the display position of the column relative to the other columns in the DataGrid.

public int DisplayIndex { get; set; }
member this.DisplayIndex : int with get, set
Public Property DisplayIndex As Integer

Property Value

The zero-based position of the column as it is displayed in the associated DataGrid. The default is the index of the corresponding Item[Int32] in the Columns collection.

Exceptions

When setting this property, the specified value is less than -1 or equal to MaxValue.

-or-

When setting this property on a column in a DataGrid, the specified value is less than zero or greater than or equal to the number of columns in the DataGrid.

When setting this property, the DataGrid is already making DisplayIndex adjustments. For example, this exception is thrown when you attempt to set DisplayIndex in a ColumnDisplayIndexChanged event handler.

-or-

When setting this property, the specified value would result in a frozen column being displayed in the range of unfrozen columns, or an unfrozen column being displayed in the range of frozen columns.

Applies to