Back to Devexpress

RowOperation.CanContinueIteration(BaseRow) Method

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

latest6.1 KB
Original Source

RowOperation.CanContinueIteration(BaseRow) Method

Returns a value indicating whether the iteration must be stopped.

Namespace : DevExpress.XtraVerticalGrid.Rows

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

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

Parameters

NameTypeDescription
rowBaseRow

A BaseRow descendant representing the processed row.

|

Returns

TypeDescription
Boolean

true to continue iteration; false to stop iteration.

|

Remarks

This method is called before the operation implemented in the RowOperation.Execute method is performed on the processed row. As implemented in the RowOperation class, the CanContinueIteration method returns true. This means that the iteration is stopped only after all rows have been processed. If this method returns false , the iteration process is stopped immediately. This can be useful when searching for a specific row as shown in the example below.

Example

The following sample code declares the FindRowItemByCaption method that searches the rows collection specified by the rows parameter for a row item with the specified caption. This method returns the first row item found.

The specified collection of rows and their children are traversed using the Rows Iterator ‘s VGridRowsIterator.DoLocalOperation method. The operation performed on the row visited is specified by the FindRowItemOperation object. Once a row item with the specified caption is found, the operation’s RowOperation.CanContinueIteration property is automatically set to false. This indicates that the operation must be stopped. The operation’s RowProperties property represents the row item with the specified caption. null ( Nothing in Visual Basic) is returned if no item is found.

csharp
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;

// ...
RowProperties prop = FindRowItemByCaption(vGridControl1, vGridControl1.Rows, "Name");

// searches the specified rows collection for a row item with the specified caption
private RowProperties FindRowItemByCaption(VGridControl vGrid, VGridRows rows , 
string caption){
   FindRowItemOperation operation = new FindRowItemOperation(caption);
   vGrid.RowsIterator.DoLocalOperation(operation, rows);
   return operation.RowProperties;
}

// declares the operation calss
public class FindRowItemOperation : RowOperation {
   string caption;
   RowProperties props;

   public FindRowItemOperation(string caption) : base() {
      this.caption = caption;
      this.props = null;
   }

   public override void Execute(BaseRow row) {
      for(int i = 0; i < row.RowPropertiesCount; i++){
         if(row.GetRowProperties(i).Caption == caption) {
            props = row.GetRowProperties(i);
            return;
         }
      }
   }

   public override bool CanContinueIteration(BaseRow row) { 
      return (RowProperties == null); 
   }

   public RowProperties RowProperties {
      get {
         return props;
      }
   }
}
vb
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraVerticalGrid.Rows

' ...
Dim prop As RowProperties = FindRowItemByCaption(VGridControl1, VGridControl1.Rows, "Name")

' searches the specified rows collection for a row item with the specified caption
Private Function FindRowItemByCaption(ByVal vGrid As VGridControl, ByVal rows As VGridRows, _
ByVal caption As String) As RowProperties
   Dim operation As FindRowItemOperation = New FindRowItemOperation(caption)
   vGrid.RowsIterator.DoLocalOperation(operation, rows)
   Return operation.RowProperties
End Function

' declares the operation calss
Public Class FindRowItemOperation
   Inherits RowOperation
   Dim caption As String
   Dim props As RowProperties

   Public Sub New(ByVal caption As String)
      Me.caption = caption
      Me.props = Nothing
   End Sub

   Public Overrides Sub Execute(ByVal row As BaseRow)
      Dim i As Integer
      For i = 0 To row.RowPropertiesCount - 1
         If row.GetRowProperties(i).Caption = caption Then
            props = row.GetRowProperties(i)
            Exit Sub
         End If
      Next i
   End Sub

   Public Overrides Function CanContinueIteration(ByVal row As BaseRow) As Boolean
      Return RowProperties Is Nothing
   End Function

   Public ReadOnly Property RowProperties() As RowProperties
      Get
         Return props
      End Get
   End Property
End Class

See Also

NeedsFullIteration

NeedsVisitChildren(BaseRow)

RowOperation Class

RowOperation Members

DevExpress.XtraVerticalGrid.Rows Namespace