MultiEditorRowPropertiesCollection.Add() Method
Creates and adds a new row item to the collection.
Namespace: DevExpress.XtraVerticalGrid.Rows
Assembly: DevExpress.XtraVerticalGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
#Declaration
public MultiEditorRowProperties Add()
#Returns
Type | Description |
---|---|
Multi |
A Multi |
#Remarks
The Add method creates a new row item and adds it to the end of the multi-editor row’s MultiEditorRow.PropertiesCollection collection. This method’s return value represents the newly created MultiEditorRowProperties object.
To add an array of existing row items to the collection, use the MultiEditorRowPropertiesCollection.AddRange method. To remove a row item from the collection, use the MultiEditorRowPropertiesCollection.Remove or MultiEditorRowPropertiesCollection.RemoveAt methods. You can also call the MultiEditorRowPropertiesCollection.Clear method to remove all row items from the collection.
#Example
The following sample code demonstrates how to create a custom row that extends the multi editor’s functionality. An additional, user-defined row property is introduced for this purpose.
Two classes are declared. The MyMultiEditorRow class derives from the MultiEditorRow class and represents a custom row. Row items for this row are represented by the MyMultiEditorRowProperties class that is derived from the MultiEditorRowProperties class. It introduces the MyProperty property that simply holds a string value. Changing the MyProperty property raises the VGridControlBase.RowChanging event.
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
// ...
MyMultiEditorRow newMultiEditorRow = new MyMultiEditorRow();
MyMultiEditorRowProperties rowItem =
newMultiEditorRow.PropertiesCollection.Add() as MyMultiEditorRowProperties;
vGridControl1.Rows.Add(newMultiEditorRow);
// ...
public class MyMultiEditorRowProperties : MultiEditorRowProperties {
string myProperty;
public MyMultiEditorRowProperties() : this(string.Empty) {}
public MyMultiEditorRowProperties(string fieldName) : base(fieldName) {
this.myProperty = string.Empty;
}
public string MyProperty {
get { return myProperty; }
set {
RowPropertiesChangingArgs args = new RowPropertiesChangingArgs(
RowChangeTypeEnum.UserProperty1, value, MyProperty);
if(CanChange(args)) {
myProperty = (string)args._value;
Changed(RowChangeTypeEnum.UserProperty1);
}
}
}
}
public class MyMultiEditorRow : MultiEditorRow {
protected override RowProperties CreateRowProperties() {
return new MyMultiEditorRowProperties();
}
}