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.v24.2.dll
Declaration
Property Value
Type | Description |
---|---|
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.
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());