Ticket Q425527
Visible to All Users

Where is the ProcessNewValue event for ComboBoxEditSettings.AddNewButtonPlacement?

created 13 years ago

I'm got a windows with a ComboBoxEdit and a DxGrid containing a ComboBox column. For both of these I want the combo box to display an "AddNew" button, so I've set the AddNewButtonPlacement property on the ComboBoxEdit and ComboBoxEditSettings for both controls. Looks good - I get the + button next to the dropdown button. Then, as described in your documentation for the ComboBoxEdit, I've used the ProcessNewValue event to generate the new value for the ItemSource. Again, this works fine. So I go to repeat the process for the ComboBoxEditSettings, but there's no ProcessNewValue event! OK, so let's check the documentation. Go to the properties for ComboBoxEditSettings and look at AddNewButtonPlacement. It tells me that this property is inherited from LookupEditSettingsBase, which is fine except that there's no documentation for that class at all! http://help.devexpress.com/#WPF/DevExpressXpfEditorsSettingsComboBoxEditSettingsMembersTopicAll

So, how do you suggest I handle a click on the "AddNew" button in a DxGrid combobox?

Answers

created 13 years ago (modified 13 years ago)

The ComboBoxEditSettings class is used to describe a column's editor and does not provide access to a real editor instance that is created at runtime. If you wish to adjust ComboBoxEdit or assign an event handler, you can accomplish this task by handling TableView's ShownEditor event in the following manner:

C#
private void view_ShownEditor(object sender, DevExpress.Xpf.Grid.EditorEventArgs e) { if (e.Column.FieldName == "ComboBoxColumn") { ComboBoxEdit comboBoxEdit = (ComboBoxEdit)e.Editor; if ((string)comboBoxEdit.Tag == "ProcessNewValueHandlerAssigned") return; comboBoxEdit.ProcessNewValue += new ProcessNewValueEventHandler(comboBoxEdit_ProcessNewValue); comboBoxEdit.Tag = "ProcessNewValueHandlerAssigned"; } } void comboBoxEdit_ProcessNewValue(DependencyObject sender, ProcessNewValueEventArgs e) { .... }

An alternative solution is to assign a custom CellTemplate to define the ComboBoxEdit explicitly instead of using the column's EditSettings:

XAML
<dxg:GridColumn FieldName="FirstName"> <dxg:GridColumn.CellTemplate> <DataTemplate> <dxe:ComboBoxEdit x:Name="PART_Editor" ProcessNewValue="comboBoxEdit_ProcessNewValue" AddNewButtonPlacement="EditBox"/> </DataTemplate> </dxg:GridColumn.CellTemplate> </dxg:GridColumn>

See also: ID Q317875, Why use EditSettings instead of CellTemplate or EditTemplate/DisplayTemplate
Feel free to post new comments if you need further assistance.

    Show previous comments (2)

      I'd like to ask if you already have implemented adding ProcessNewValue into the LookupEditSettings class? I need this functionality all of the time all over the application.

      DevExpress Support Team 11 years ago

        Hi,
        This event is not implemented yet. As far as I understand, you're looking for a solution to handle ProcessNewValue in an MVVM way. We will answer you in the Suggested way to handle ProcessNewValue from ComboBoxEditSettings MVVM way ticket.

        RC RC
        Radosław Czwojdrak 9 years ago

          Thank you, that worked :)

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.