Gets or sets a position in GridControl.Nodes or parent Row.Children. By setting a new index, you can move this Row in grid.

Namespace: Dapfor.Wpf.Controls
Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)

Syntax

C#
public int ChildIndex { get; set; }
Visual Basic
Public Property ChildIndex As Integer
	Get
	Set
Visual C++
public:
property int ChildIndex {
	int get ();
	void set (int value);
}
F#
member ChildIndex : int with get, set

Property Value

Type: Int32
Index in GridControl.Nodes or parent Row.Children.

Remarks

The GridControl has two row indexing system. Rows performs linear indexing of visible rows in a grid without regard to hierarchy. It means that this collection contains all visible (not filtered and non-collapsed by parent) rows. VisibleIndex property specifies position of a visible row in Rows. The second time of indexing is related to hierarchical structure of the grid. Rows at the first hierarchy level can be accessed with GridControl.Nodes property. This collection contains both visible and invisible rows that are located on the same hierarchy level. Every row may contain child rows that can be accessed via Children property. Neither filtering, nor visibility affect row presence in this collection. ChildIndex property defines hierarchical position of a row If the row is on the top level, it is in Nodes, otherwise it is in parent Children container. The row also has VisibleChildren container that contains only visible children on the same hierarchy level. You can use VisibleChildIndex property to determine Row position in VisibleChildren of the parent.

One row can be present in different containers, including GridControl.Rows, GridControl.Nodes, Row.Children, etc. Containers organize grid structure and enable precise definition of data location. For hierarchies the grid provides a convenient API that can be used to determine parent, children and adjacent visible rows. The list of most frequent methods and properties used for data indexing is provided below.

Considering all the above, you may move rows with Row.ChildIndex only if the grid is not sorted. This property has been selected because it defines row position in the grid disregarding hierarchy and visibility of previous rows.

 Copy imageCopy
public void MoveToTop(Row row)
{
    row.ChildIndex = 0;
}

public void MoveToBottom(Row row)
{
    Row parent = row.Parent;
    row.ChildIndex = parent != null
        ? parent.Children.Count - 1
        : row.Grid.Nodes.Count - 1;
}

See Also