ParentRow Property
Description
Reference to the parent row if this row is a child.
Property Type
Read-only property
Syntax (Visual Basic)
Public Property ParentRow() As [GridRow](XtremeGridControl~GridRow.md)
Remarks
If the GridRecord attached to the row does not have any children, then the ParentRow is Nothing\NULL. ParentRow can be used to determine if the row is a child. It can also be used to find the parent of a child row so the children can be expanded or hidden. By setting the expanded property of the parent to False, all children will be hidden.
Example
ParentRow Sample (Visual Basic)
This sample illustrates one way to use the ParentRow property. The KeyDown event is used to determine when both the Delete and Ctrl keys are pressed, then the currently selected row along with all parent and sibling rows are removed.
' The KeyDown event can be used to determine if any key combination has been pressed
Private Sub wndGridControl_KeyDown(KeyCode As Integer, Shift As Integer)
' If both the Delete key and the Ctrl key are pressed, execute this code
If (KeyCode = 46 And Shift = 2) Then
' If a row has focus, then execute this code
If Not wndGridControl.FocusedRow Is Nothing Then
' If the row with focus has a ParentRow, then execute this code
If Not wndGridControl.FocusedRow.ParentRow Is Nothing Then
Dim Row As GridRow
Set Row = wndGridControl.FocusedRow.ParentRow
' Determine the root (row with no ParentRow) ParentRow to ALL children, this may iterate several
' times before the root (row with no ParentRow) ParentRow has been found.
While Not Row.ParentRow Is Nothing
Set Row = Row.ParentRow
Wend
' Delete the root row. This will delete the root row and ALL children rows.
' The RemoveAt method is used to remove the Records attached to the root row,
' which removes all child records.
wndGridControl.Records.RemoveAt Row.Index
Else
' This row has no ParentRow, so it is already the root row and can be removed
' with no further action
wndGridControl.Records.RemoveAt wndGridControl.FocusedRow.Index
End If
' Any time you add or delete rows (by removing the attached record), you must call the
' Populate method so the GridControl will display the changes, the rows will remain
' visible until the Populate method is called
wndGridControl.Populate
End If
End If
End Sub
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.