Back to Devexpress

RowOperation.NeedsVisitChildren(BaseRow) Method

windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-rowoperation-dot-needsvisitchildren-x28-devexpress-dot-xtraverticalgrid-dot-rows-dot-baserow-x29.md

latest4.6 KB
Original Source

RowOperation.NeedsVisitChildren(BaseRow) Method

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

Declaration

csharp
public virtual bool NeedsVisitChildren(
    BaseRow row
)
vb
Public Overridable Function NeedsVisitChildren(
    row As BaseRow
) As Boolean

Parameters

NameTypeDescription
rowBaseRow

A BaseRow descendant representing the processed row whose child rows are to be visited.

|

Returns

TypeDescription
Boolean

true if the operation must be performed on the specified row’s children; otherwise, false.

|

Example

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.

csharp
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;
}
vb
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

NeedsFullIteration

Tree Traversal

RowOperation Class

RowOperation Members

DevExpress.XtraVerticalGrid.Rows Namespace