private void Form1_Load(object sender, EventArgs e) { C1FlexGrid _flex; ListDictionary _countryList; ListDictionary _indianStates; ListDictionary _japaneseStates; ListDictionary _americanStates; CellStyle _cellStyle1; CellStyle _cellStyle2; CellStyle _cellStyle3; _flex = new C1FlexGrid(); _flex.Dock = DockStyle.Fill; this.Controls.Add(_flex); _flex.Cols[1].Caption = "Country"; _flex.Cols[2].Caption = "States"; _countryList = new ListDictionary(); _countryList.Add("1", "India"); _countryList.Add("2", "Japan"); _countryList.Add("3", "USA"); _flex.Cols[1].DataMap = _countryList; //Creating different Cell Styles with different DataMaps _indianStates = new ListDictionary(); _indianStates.Add("1", "Punjab"); _indianStates.Add("2", "Assam"); _indianStates.Add("3", "UP"); _cellStyle1 = _flex.Styles.Add("IndianStatesDataMap"); _cellStyle1.DataMap = _indianStates; _japaneseStates = new ListDictionary(); _japaneseStates.Add("1", "Osaka"); _japaneseStates.Add("2", "Toyama"); _japaneseStates.Add("3", "Akita"); _cellStyle2 = _flex.Styles.Add(""JapaneseStatesDataMap""); _cellStyle2.DataMap = _japaneseStates; _americanStates = new ListDictionary(); _americanStates.Add("1", "Florida"); _americanStates.Add("2", "California"); _americanStates.Add("3", "NewYork"); _cellStyle3 = _flex.Styles.Add("AmericanStatesDataMap"); _cellStyle3.DataMap = _americanStates; _flex.ValidateEdit += _flex_ValidateEdit; ; } private void _flex_ValidateEdit(object sender, ValidateEditEventArgs e) { if (_flex.ComboBoxEditor != null && e.Col==1) { object selectedKey = _flex.ComboBoxEditor.SelectedKey; switch (selectedKey.ToString()) { case "1": _flex.SetCellStyle(e.Row, e.Col + 1, _cellStyle1); break; case "2": _flex.SetCellStyle(e.Row, e.Col + 1, _cellStyle2); break; case "3": _flex.SetCellStyle(e.Row, e.Col + 1, _cellStyle3); break; } } }
System.Object
C1.Win.C1FlexGrid.ComboBoxEditor