/// <summary> /// Adds a combobox column that is bounded to another Column (bounded column) /// (all combobox cells have different itemSources /// </summary> /// <param name="srcColumnName">the name of the column that the combobox column is bounded to</param> /// <param name="itemListSource">the ItemSources for the ItemLists of the combobox cells</param> /// <param name="configurationType">configuration type</param> /// <param name="sortItemList">sort the itemLists?</param> public void AddCellBoundedComboBox(string srcColumnName, BindingList <object> itemListSource, ComboboxConfigType configurationType, bool sortItemList) { ComboBoxConfiguration comboConfig = GetComboBoxConfigFromSingleDataSource(itemListSource, configurationType, sortItemList); AddCellBoundedComboBox(srcColumnName, comboConfig); }
/// <summary> /// Adds a combobox column that is bounded to another Column (bounded column) /// (all combobox cells have different itemSources /// </summary> /// <param name="srcColumnName">the name of the column that the combobox column is bounded to</param> /// <param name="itemListSource">the ItemSources for the ItemLists of the combobox cells</param> /// <param name="configurationType">configuration type</param> /// <param name="sortItemList">sort the itemLists?</param> public void AddCellBoundedComboBox(string srcColumnName, Dictionary <object, BindingList <object> > itemListSource, ComboboxConfigType configurationType, bool sortItemList) { ComboBoxConfiguration comboConfig = new ComboBoxConfiguration(itemListSource, configurationType, sortItemList); AddCellBoundedComboBox(srcColumnName, comboConfig); }
/// <summary> /// Creates a new ComboBoxConfiguration with a single itemSource for all combobox cell of a combobox column /// </summary> /// <param name="srcColumnName">the name of the column that the combobox column is bounded to</param> /// <param name="itemListSource">the ItemSource for the ItemList of all combobox cells</param> /// <param name="sortItemList">sort the itemLists?</param> /// <returns>configation for a comboBoxColumn</returns> private ComboBoxConfiguration GetComboBoxConfigFromSingleDataSource(BindingList <object> itemListSource, ComboboxConfigType configurationType, bool sortItemList) { Dictionary <object, BindingList <object> > dataSourceDictionary = new Dictionary <object, BindingList <object> >(); foreach (DataGridViewRow row in this.Rows) { dataSourceDictionary.Add(row.DataBoundItem, itemListSource); } //only one registration is necessary because all datasources are equal itemListSource.ListChanged += DataSource_ListChanged; //Create combobox configuration and add item source template for adding new columns ComboBoxConfiguration comboConfig = new ComboBoxConfiguration(dataSourceDictionary, configurationType, sortItemList); comboConfig.AddItenSourceTemplate(itemListSource); return(comboConfig); }