windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-baserow-0c293dbf.md
Gets a collection of child rows for a row.
Namespace : DevExpress.XtraVerticalGrid.Rows
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
[Browsable(false)]
[XtraSerializableProperty(true, true, true)]
public VGridRows ChildRows { get; }
<Browsable(False)>
<XtraSerializableProperty(True, True, True)>
Public ReadOnly Property ChildRows As VGridRows
| Type | Description |
|---|---|
| VGridRows |
A VGridRows object representing a collection of child rows (if any) for a row.
|
Use the returned object’s methods and properties to manage the row’s collection of child rows. You can add, delete and access individual rows, enabling you to build and manage the row’s tree structure. Root rows can be accessed via the control’s VGridControlBase.Rows property.
Use the BaseRow.HasChildren property to determine if a row has children. You can also use the BaseRow.HasAsChild method to check if a specific row is a row’s child row.
If the row has no children, the ChildRows property returns an empty collection.
The following example demonstrates how to move the focused row to a specific category row. The example assumes that a grid control has a particular category row whose name is categoryRow_Notes among its rows.
The image below displays the look & feel of a grid control before and after execution of the sample code.
Note that the code listed below is cited as an example of using the different properties of a row object (such as BaseRow.ChildRows, BaseRow.HasAsParent, BaseRow.ParentRow). You can achieve the same results more easily by using the grid’s VGridControlBase.MoveRow method.
private void MoveFocusedToCategory() {
BaseRow focusedRow = vGridControl1.FocusedRow;
BaseRow categoryRow = vGridControl1.Rows["categoryRow_Notes"];
// checking whether the focused row already belongs to the category or
// becomes the category row itself
if (!(focusedRow.HasAsParent(categoryRow) | focusedRow == categoryRow)) {
// checking whether the focused row has a parent row or represents a root level row
if (focusedRow.ParentRow == null) {
// removing an object representing the focused row from
// the grid's collection of top level rows
vGridControl1.Rows.Remove(focusedRow);
}
else {
// removing an object representing the focused row from
// the rows collection of its parent row
focusedRow.ParentRow.ChildRows.Remove(focusedRow);
}
// adding an object representing the focused row
//to the end of the category row's chil rows collection
categoryRow.ChildRows.Add(focusedRow);
}
}
Private Sub MoveFocusedToCategory()
Dim FocusedRow As BaseRow = VGridControl1.FocusedRow
Dim CategoryRow As BaseRow = VGridControl1.Rows("categoryRow_Notes")
' checking whether the focused row already belongs to the category
' or becomes the category row itself
If Not (FocusedRow.HasAsParent(CategoryRow) Or FocusedRow Is CategoryRow) Then
' checking whether the focused row has a parent row
' or represents a root level row
If FocusedRow.ParentRow Is Nothing Then
' removing an object representing the focused row
' from the grid's collection of top level rows
VGridControl1.Rows.Remove(FocusedRow)
Else
' removing an object representing the focused row
' from the rows collection of its parent row
FocusedRow.ParentRow.ChildRows.Remove(FocusedRow)
End If
' adding an object representing the focused row
' to the end of the category row's chil rows collection
CategoryRow.ChildRows.Add(FocusedRow)
End If
End Sub
See Also