Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
640
Different XamComboBox values each Row/Record
posted

Hi,

I have a datagrid with a few rows.

Each row has a different Part (as in Part from a Car). Depending on the Part the ComboBox values have to be different.

So if I select the Part Wheel the Combobox values have to be something like (Piece, Crate).
When I select the Part Cable the Combobox values have to be something like (Meters, Box).

With the code provided I can set the values with a style, but the last set style is leading for every Combobox. The last style overwrites every style set earlier. 

What am I doing wrong? 
How can I give each new row new ComboBox  values?

Here is the code:

dataGrid.InitializeRecord += new EventHandler<Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs>(dataGrid_InitializeRecord);

        private void dataGrid_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)
        {
            DataRecord dr = e.Record as DataRecordif (dr != null)
            {
                foreach (Cell cell in dr.Cells)
                {
                    if (cell.Field.Name.ToString() == "UNITCONVERTERID")
                    {
                        UnitConverter unitConverter = UnitConverterManager.GetNewUnitConverter();
                        ComboBoxItemsProvider lookUpItems = new ComboBoxItemsProvider();
                        XamComboEditor xamComboBox = sender as XamComboEditor;
                        
                        BizObj bizObj = GetBizObjFromDataRecord(dr);

                        if ((bizObj != null) && (bizObj.GetType() == typeof(HourCostLine)) && ((bizObj as HourCostLine).ItemObj != null))
                        {
                            if (bizObj.ID == 1)
                            {
                                unitConverter.Unit = "Pieces";
                                unitConverter.ID = 0;

                                // a unique ValueList
                                lookUpItems.DisplayMemberPath = "Unit";
                                lookUpItems.ValuePath = "ID";
                                lookUpItems.Items.Add(unitConverter);

                                Setter setter = new Setter();
                                setter.Property = XamComboEditor.ItemsProviderProperty;
                                setter.Value = lookUpItems;

                                // Add the setter to the style and assign to this field
                                Style style = new Style(typeof(XamComboEditor));
                                style.Setters.Add(setter);
                                cell.Field.Settings.EditorStyle = style;
                            }
                            else
                            {
                                unitConverter.Unit = "Meters";
                                unitConverter.ID = 1;

                                // a unique ValueList
                                lookUpItems.DisplayMemberPath = "Unit";
                                lookUpItems.ValuePath = "ID";
                                lookUpItems.Items.Add(unitConverter);

                                Setter setter = new Setter();
                                setter.Property = XamComboEditor.ItemsProviderProperty;
                                setter.Value = lookUpItems;

                                // Add the setter to the style and assign to this field
                                Style style = new Style(typeof(XamComboEditor));
                                style.Setters.Add(setter);
                                cell.Field.Settings.EditorStyle = style;
                            }

                        }
                        
                    }

                }

            }

        }

 

Thanks in advance,

Patrick