Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Re: In-code CellEditor for column edit

  •  04-27-2008, 3:51 PM

    Re: In-code CellEditor for column edit

    Got it:

     

                List<String> itemList = new List<String>();
                itemList.Add("NW");
                itemList.Add("N");
                itemList.Add("NE");
                itemList.Add("E");
                itemList.Add("SE");
                itemList.Add("S");
                itemList.Add("SW");
                itemList.Add("W");

                Binding binding = new Binding();
                binding.Source = itemList;

                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ComboBox));
                factory.SetValue(ComboBox.ItemsSourceProperty, binding);

                Xceed.Wpf.DataGrid.Markup.CellEditorBindingExtension cellEditorBindingExtension = new Xceed.Wpf.DataGrid.Markup.CellEditorBindingExtension();
                factory.SetValue(ComboBox.SelectedValueProperty, cellEditorBindingExtension.ProvideValue(null) as BindingBase);

                DataTemplate editTemplate = new DataTemplate(typeof(ComboBox));
               
                editTemplate.VisualTree = factory;

                CellEditor cellEditor = new CellEditor();
                cellEditor.EditTemplate = editTemplate;
                dataGridControl.Columns[0].CellEditor = cellEditor;

    This post was very helpful, as well as the one Jenny referenced above. The post I just linked pointed out that I'd need a new CellEditor or all of my editors will inherit the new combo box, as well as showed how ot use the CellEditorBindingExtension.

View Complete Thread
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.