Export (0) Print
Expand All

DataGridColumn.DisplayIndex Property

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

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

public int DisplayIndex { get; set; }
<sdk:dataGridColumn DisplayIndex="int"/>

XAML Values

sdk:dataGridColumn

Typically, sdk:DataGridTextColumn, sdk:DataGridCheckBoxColumn, or sdk:DataGridTemplateColumn.

Property Value

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

ExceptionCondition
ArgumentOutOfRangeException

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.

InvalidOperationException

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 DataGrid.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.

The DisplayIndex property value must always correspond to one of the index values of the Items in the DataGrid.Columns collection for a column in the same DataGrid. The display index is automatically adjusted when columns are inserted or removed from the Columns collection.

Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft