只需修改一个属性,写一个事件:
CheckedComboBoxEdit1.Properties.SelectAllItemVisible = false;//下拉框设置成不可全选
#region CheckedComboBoxEdit设置成单选框
private void CheckedComboBoxEdit1_Popup(object sender, EventArgs e)
{
CheckedListBoxControl checkedListBoxControl = (sender as IPopupControl)?.PopupWindow.Controls.OfType<PopupContainerControl>().First().Controls.OfType<CheckedListBoxControl>().First();
if (checkedListBoxControl != null)
{
checkedListBoxControl.ItemCheck -= checkedListBoxControl_ItemCheck;
checkedListBoxControl.ItemCheck += checkedListBoxControl_ItemCheck;
}
}
private void checkedListBoxControl_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;
}
}
#endregion