Skip to main content

MultiEditorRowPropertiesCollection.AddRange(MultiEditorRowProperties[]) Method

Adds an array of MultiEditorRowProperties objects to the collection of row items.

Namespace: DevExpress.XtraVerticalGrid.Rows

Assembly: DevExpress.XtraVerticalGrid.v24.1.dll

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

Declaration

public void AddRange(
    MultiEditorRowProperties[] props
)

Parameters

Name Type Description
props MultiEditorRowProperties[]

An array of MultiEditorRowProperties objects to be added to the row item collection of a multi-editor row.

Remarks

An array of row items represented by row properties objects is passed to this method as a parameter. Each row item is a MultiEditorRowProperties class instance. You can use the AddRange method to quickly add a group of row items to the row item collection of a multi-editor row. The collection is represented by a MultiEditorRowPropertiesCollection object which can be accessed via the row’s MultiEditorRow.PropertiesCollection property.

Using this method is the only way to add already existing row items (which have been created programmatically with the help of their constructors) to the MultiEditorRow.PropertiesCollection. If there is a necessity to create a new row item, either with default settings or bound to a specific data field, you can use a particular overloading version of the MultiEditorRowPropertiesCollection.Add method.

The VGridControlBase.RowChanged event occurs after all items of the passed props array have been added to the collection. The event parameter’s RowChangedEventArgs.ChangeType property, representing the type of row processing performed, returns the RowChangeTypeEnum.PropertiesAdded value.

To remove a specific row item from the MultiEditorRow.PropertiesCollection, use the MultiEditorRowPropertiesCollection.Remove or the MultiEditorRowPropertiesCollection.RemoveAt method. You can use the MultiEditorRowPropertiesCollection.Clear method if you want to remove all row items from the collection.

Example

The example below demonstrates how to use both available constructors of the MultiEditorRowProperties class, the MultiEditorRow.PropertiesCollection property and MultiEditorRowPropertiesCollection.AddRange method. The sample code creates two MultiEditorRowProperties objects representing items for a multi-editor row created at runtime as well. The row is intended to represent and edit the values of two data fields (MPG City and MPG Highway) containing information about the fuel efficency of cars. Since the bound fields are of an identical data type, both row items will use the same editor of the SpinEdit type to display and edit their data. Created row items are arrayed and added to the row’s MultiEditorRow.PropertiesCollection with the help of the MultiEditorRowPropertiesCollection.AddRange method.

In the end of the example code’s execution, the multi-editor row containing two row items is added to the grid’s VGridControlBase.Rows collection.

using DevExpress.XtraVerticalGrid.Rows;
using DevExpress.XtraEditors.Repository;

// creating the first row item, specifying its caption and binding it to a data field
MultiEditorRowProperties rowItem1 = new MultiEditorRowProperties();
rowItem1.Caption = "MPG City";
rowItem1.FieldName = "MPG City";

// creating the second row item bound to a data field and specifying its caption 
MultiEditorRowProperties rowItem2 = new MultiEditorRowProperties("MPG Highway");
rowItem2.Caption = "MPG Highway";

// assigning the same editor for the created row items
RepositoryItemSpinEdit riSpin = vGridControl1.RepositoryItems.Add("SpinEdit") as 
  RepositoryItemSpinEdit;
rowItem1.RowEdit = riSpin;
rowItem2.RowEdit = riSpin;

// creating a new multi-editor row instance
MultiEditorRow newMultiEditorRow = new MultiEditorRow();
// assigning the name to the created multi-editor row
newMultiEditorRow.Name = "multiEditorRow_MPG";

// adding arrayed items to the item collection of the newly created multi-editor row
MultiEditorRowProperties [] rowItems = new MultiEditorRowProperties [2] {rowItem1, rowItem2};
newMultiEditorRow.PropertiesCollection.AddRange(rowItems);

// appending the multi-editor row to a collection of top level grid rows
vGridControl1.Rows.Add(newMultiEditorRow);
See Also