windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-rowoperation-dot-needsvisitchildren-x28-devexpress-dot-xtraverticalgrid-dot-rows-dot-baserow-x29.md
Returns a value specifying whether the operation is performed on the specified row’s children.
Namespace : DevExpress.XtraVerticalGrid.Rows
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
public virtual bool NeedsVisitChildren(
BaseRow row
)
Public Overridable Function NeedsVisitChildren(
row As BaseRow
) As Boolean
| Name | Type | Description |
|---|---|---|
| row | BaseRow |
A BaseRow descendant representing the processed row whose child rows are to be visited.
|
| Type | Description |
|---|---|
| Boolean |
true if the operation must be performed on the specified row’s children; otherwise, false.
|
This sample demonstrates how to obtain the collection of rows residing at a specific level and prevent them from being resized. For this purpose, the operation class declares a local variable storing the level index. This variable is initialized in the constructor. If a row that belongs to the specified level is found, it is added to the internal rows collection. The operation class also declares a public property that allows access to the collection of obtained rows.
The operation class introduced in the sample overrides the RowOperation.NeedsVisitChildren method of its base class. This is used to prohibit visiting rows whose nesting level is greater than that specified, improving performance.
public class GetRowsAtLevelOperation : RowOperation {
int level;
ArrayList rows;
public GetRowsAtLevelOperation(int level) : base() {
this.level = level;
rows = new ArrayList();
}
public override void Execute(BaseRow row) {
if (row.Level == level)
rows.Add(row);
}
public override bool NeedsVisitChildren(BaseRow row) {
if (row.Level == level)
return false;
return true;
}
public ArrayList Rows { get { return rows; } }
}
// ...
// Prevent rows at the second nesting level from being resized
GetRowsAtLevelOperation operation = new GetRowsAtLevelOperation(1);
vGridControl1.RowsIterator.DoOperation(operation);
foreach (object rowObject in operation.Rows) {
BaseRow row = rowObject as BaseRow;
row.OptionsRow.AllowSize = false;
}
Public Class GetRowsAtLevelOperation
Inherits RowOperation
Dim level As Integer
Dim _rows As ArrayList
Public Sub GetRowsAtLevelOperation(ByVal level As Integer)
Me.level = level
_rows = New ArrayList()
End Sub
Public Overrides Sub Execute(ByVal row As BaseRow)
If row.Level = level Then
_rows.Add(row)
End If
End Sub
Public Overrides Function NeedsVisitChildren(ByVal row As BaseRow) As Boolean
If row.Level = level Then
Return False
End If
Return True
End Function
Public ReadOnly Property rows() As ArrayList
Get
Return _rows
End Get
End Property
End Class
' ...
' Prevent rows at the second nesting level from being resized
Dim operation As New GetRowsAtLevelOperation(1)
VGridControl1.RowsIterator.DoOperation(operation)
Dim rowObject As Object
For Each rowObject In operation.rows
Dim row As BaseRow = rowObject
row.OptionsRow.AllowSize = False
Next rowObject
See Also