private void Form1_Load(object sender, EventArgs e) { for (int i = 0; i < coloursArr.Length; i++) { CheckedComboBoxItem item = new CheckedComboBoxItem(coloursArr[i], i); CheckedComboBox1.Items.Add(item); } // If more then 5 items, add a scroll bar to the dropdown. CheckedComboBox1.MaxDropDownItems = 5; // Make the "Name" property the one to display, rather than the ToString() representation. CheckedComboBox1.DisplayMember = "Name"; CheckedComboBox1.ValueSeparator = "; "; // Check the first 2 items. CheckedComboBox1.SetItemChecked(0, true); CheckedComboBox1.SetItemChecked(1, true); //ccb.SetItemCheckState(1, CheckState.Indeterminate); }
private void ccb_ItemCheck(object sender, ItemCheckEventArgs e) { CheckedComboBoxItem item = CheckedComboBox1.Items[e.Index] as CheckedComboBoxItem; txtOut.AppendText(string.Format("Item '{0}' is about to be {1}\r\n", item.Name, e.NewValue.ToString())); }