DataGridColumn.DisplayIndex Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
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)
Syntax
'Declaration
Public Property DisplayIndex As Integer
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.
Exceptions
Exception | Condition |
---|---|
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. |
Remarks
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.
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
See Also