We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to automatically change GridMultiColumnDropDownList ItemsSource if the user type a code that does not exist?

Thread ID:





131149 Jun 23,2017 02:41 PM UTC Jun 29,2017 01:45 AM UTC WPF 3
Tags: SfDataGrid
Asked On June 23, 2017 02:41 PM UTC


please find here attached an example that I have modified to ask you a question and a video where I better explain my question (Question about GridMultiColumnDropDownList.wmv).

I have a GridMultiColumnDropDownList column that is binded to a collection of Product objects named ProductList.
The user can edit the cells in this column, but by default, if he types a Product Code that does not exist and presses Enter, his changes are not considered since the inserted Code is not found in the underlying collection.
But I'd like, instead, that, if a user types a Code that does not exist in the binded collection, a new Product is automatically created (with a new incremental ID) and added to the ProductList collection. So everything the user types in the column, even if it does not exist as a Code, it is automatically added to the Product collection and Order object is correctly updated with the user's changes.

Is it possible to implement such a behaviour?
Can you suggest me any idea?

Thank you.


Attachment: Combo_columns_for_grids_3001a5d7.zip

Srinivasan Vasu [Syncfusion]
Replied On June 27, 2017 09:41 AM UTC

Hi Silvio, 
Sorry for delay caused. 
We have checked your query and we have prepared a sample as per your requirement. You can achieve your requirement by customizing the GridCellMultiColumnDropDownRenderer. 
Please refer the below code. 
   this.Grid.CellRenderers.Add("MultiColumnDropDown", new MultiDropDownRenderer()); 
public class MultiDropDownRenderer: GridCellMultiColumnDropDownRenderer 
        protected override bool ShouldGridTryToHandleKeyDown(KeyEventArgs e) 
            if (e.Key == Key.Enter) 
                var multiDropDown = (this.CurrentCellRendererElement as SfMultiColumnDropDownControl); 
                var textBox = multiDropDown.GetType().GetProperty("Editor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(multiDropDown);                 
                var newValue = textBox != null ? (textBox as TextBox).Text : null; 
                var underlyingItems = (this.DataGrid.DataContext as ViewModel).ProductList; 
                if (underlyingItems != null) 
                    bool newRecord = underlyingItems.Any(x => x.Code == newValue.ToString()); 
                    if (!newRecord) 
                        underlyingItems.Add(new ProductInfo() { Code = newValue.ToString(), ID = underlyingItems.Count + 1  }); 
                        multiDropDown.SelectedItem = underlyingItems.Last(); 
            return base.ShouldGridTryToHandleKeyDown(e); 
Please download the sample from the below location. 

Replied On June 28, 2017 09:37 AM UTC

very very helpful!

Thank you!

Srinivasan Vasu [Syncfusion]
Replied On June 29, 2017 01:45 AM UTC

Hi Silvio, 
Thanks for your update. 
Please let us know if need further asssitance. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon