Back to Devexpress

VGridControlBase.RecordsIterator Property

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-eddbeaf6.md

latest4.7 KB
Original Source

VGridControlBase.RecordsIterator Property

Allows you to iterate all available records, or only records that are currently visible (fit the currently applied filter), and perform a custom operation on the iterated records.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
public VGridRecordsIterator RecordsIterator { get; }
vb
<Browsable(False)>
Public ReadOnly Property RecordsIterator As VGridRecordsIterator

Property Value

TypeDescription
DevExpress.XtraVerticalGrid.Rows.VGridRecordsIterator

A DevExpress.XtraVerticalGrid.Rows.VGridRecordsIterator object that iterates records.

|

Example

The following example shows how to iterate VGridControl‘s records that fit the currently applied filter, and count them.

The VGridControlBase.RecordsIterator property provides facilities to iterate records, and perform a custom operation on each iterated record. The RecordsIterator.DoOperation method invokes the iteration process, and takes the operation performed on each iterated record as a parameter.

The operation is a DevExpress.XtraVerticalGrid.Rows.RecordOperation descendant, which implements the Execute method. This method accepts the index argument that specifies the index of the processed record. Implement this method in your custom operation.

Besides, the DevExpress.XtraVerticalGrid.Rows.RecordOperation abstract class exposes the following virtual methods that can be overridden:

  • the CanVisitInvisibleRecords property - gets whether to visit nodes that do not fit the currently applied filter (i.e., visit all nodes). Returns true if not overridden;

  • the Init method - called before the iteration process. If you perform successive record updates in the operation, call VGridControlBase.BeginUpdate in this method;

  • the Release method - called after the iteration process. If you called VGridControlBase.BeginUpdate in the Init method, call VGridControlBase.EndUpdate.

  • C#

  • VB.NET

csharp
class CountVisibleRecordsOperation : DevExpress.XtraVerticalGrid.Rows.RecordOperation {
    int i = 0;
    // Called for each iterated record.
    // The index parameter passes the index of the precessed record.
    public override void Execute(int index) { i++; }
    // Gets whether to visit records that does not fit the currently applied filter.
    // Returns true if not overridden.
    public override bool CanVisitInvisibleRecords { get { return false; } }
    // Called before the iteration process.
    public override void Init() { }
    // Called after the iteration process.
    public override void Release() { }
}
// ...
vGridControl1.RecordsIterator.DoOperation(new CountVisibleRecordsOperation());
vb
Class CountVisibleRecordsOperation
    Inherits DevExpress.XtraVerticalGrid.Rows.RecordOperation
    Private i As Integer = 0
    ' Called for each iterated record.
    ' The index parameter passes the index of the precessed record.
    Public Overrides Sub Execute(index As Integer)
        i = i + 1
    End Sub
    ' Gets whether to visit records that does not fit the currently applied filter.
    ' Returns true if not overridden.
    Public Overrides ReadOnly Property CanVisitInvisibleRecords() As Boolean
        Get
            Return False
        End Get
    End Property
    ' Called before the iteration process.
    Public Overrides Sub Init()
    End Sub
    ' Called after the iteration process.
    Public Overrides Sub Release()
    End Sub
End Class
' ...
vGridControl1.RecordsIterator.DoOperation(New CountVisibleRecordsOperation())

See Also

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace