I have reviewed a couple of options from your documentation to handle ProcessNewValue event but hasn't fully got what is the recommended way to do the below tasks with MVVM with the current version of DXGrid
- process the new value only when the user hits enter (now in the below code it will processed on every letter insert)
- on value processing handler, add the new object to itemssource where the newly entered String will be set to object's DisplayMember property
- if AddNewButtonPlacement is specified, open a dialog to enter values for the new object
Current code (which requires code-behind):
C#<dxg:GridColumn FieldName="parentID">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings AutoComplete="True" ImmediatePopup="True" IncrementalFiltering="True" IsTextEditable="True" ItemsSource="{Binding MyParent.Childrents, Mode=TwoWay}" ValueMember="Id" DisplayMember="Name" AddNewButtonPlacement="Popup" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
C#<dxg:TableView ShownEditor="view_ShownEditor">
Visual BasicPrivate Sub view_ShownEditor(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.EditorEventArgs)
If e.Column.FieldName = "parentID" Then
Dim comboBoxEdit As ComboBoxEdit = DirectCast(e.Editor, ComboBoxEdit)
If DirectCast(comboBoxEdit.Tag, String) = "ProcessNewValueHandlerAssigned" Then
Return
End If
AddHandler comboBoxEdit.ProcessNewValue, AddressOf comboBoxEdit_ProcessNewValue
comboBoxEdit.Tag = "ProcessNewValueHandlerAssigned"
End If
End Sub
Private Sub comboBoxEdit_ProcessNewValue(ByVal sender As DependencyObject, ByVal e As ProcessNewValueEventArgs)
'process value here...
End Sub