DevExpress

checkedComboBoxEdit multi select

windbear 2021. 3. 16. 11:27
반응형

WindowsFormsApp2.zip
0.04MB

checkedComboBoxEdit multi select false

private void checkedComboBoxEdit1_Popup(object sender, EventArgs e)
        {
            CheckedListBoxControl list = (sender as IPopupControl).PopupWindow.Controls.OfType<PopupContainerControl>().First().Controls.OfType<CheckedListBoxControl>().First();

            list.ItemCheck -= list_ItemCheck;
            list.ItemCheck += list_ItemCheck;
        }
        void list_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e)
        {
            if (e.State == CheckState.Checked)
            {
                CheckedListBoxControl list = sender as CheckedListBoxControl;
                List<CheckedListBoxItem> items = new List<CheckedListBoxItem>();
                foreach (int index in list.CheckedIndices)
                {
                    if (index == e.Index) continue;
                    items.Add(list.Items[index]);
                } 
                foreach (CheckedListBoxItem item in items)
                    item.CheckState = CheckState.Unchecked;
                
            }
        }
반응형