RowOperation.Execute(BaseRow) Method

Performs the operation on the visited row.

Namespace: DevExpress.XtraVerticalGrid.Rows

Assembly: DevExpress.XtraVerticalGrid.v20.2.dll

Declaration

public abstract void Execute(
    BaseRow row
)
Public MustOverride Sub Execute(
    row As BaseRow
)

Parameters

Name Type Description
row BaseRow

A BaseRow descendant representing the processed row against which the operation is performed.

Remarks

When creating the operation class, you must override the Execute method to implement the specific operation performed by the rows iterator. The Execute method is called each time a row is visited. The visited row is passed to this method as the parameter.

Refer to the Tree Traversal topic for more information on using the Rows Iterator.

Examples

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.

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;
      }
   }
}
See Also