windowsforms-devexpress-dot-xtraverticalgrid-dot-rows-dot-multieditorrowpropertiescollection-4560af25.md
Creates and adds a new row item to the collection.
Namespace : DevExpress.XtraVerticalGrid.Rows
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
public MultiEditorRowProperties Add()
Public Function Add As MultiEditorRowProperties
| Type | Description |
|---|---|
| MultiEditorRowProperties |
A MultiEditorRowProperties object representing the newly created row item.
|
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.
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();
}
}
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraVerticalGrid.Rows
' ...
Dim newMultiEditorRow As MyMultiEditorRow = New MyMultiEditorRow()
Dim rowItem As MyMultiEditorRowProperties = newMultiEditorRow.PropertiesCollection.Add()
VGridControl1.Rows.Add(newMultiEditorRow)
' ...
public class MyMultiEditorRowProperties
Inherits MultiEditorRowProperties
Dim _myProperty As String
Public Sub New()
MyClass.New(String.Empty)
End Sub
Public Sub New(ByVal fieldName As String)
Me._myProperty = String.Empty
End Sub
Public Property MyProperty() As String
Get
Return _myProperty
End Get
Set(ByVal Value As String)
Dim args As RowPropertiesChangingArgs = New RowPropertiesChangingArgs( _
RowChangeTypeEnum.UserProperty1, Value, MyProperty)
If (CanChange(args)) Then
_myProperty = CType(args._value, String)
Changed(RowChangeTypeEnum.UserProperty1)
End If
End Set
End Property
End Class
Public Class MyMultiEditorRow
Inherits MultiEditorRow
Protected Overrides Function CreateRowProperties() As RowProperties
Return New MyMultiEditorRowProperties()
End Function
End Class
See Also
AddRange(MultiEditorRowProperties[])
MultiEditorRowPropertiesCollection Class