protected override void OnCheckedChanged(EventArgs e) { base.OnCheckedChanged(e); // If this item is no longer in the checked state or if its // parent has not yet been initialized, do nothing. if (!Checked || this.Parent == null) { return; } // Clear the checked state for all siblings. foreach (ToolStripItem item in Parent.Items) { ToolStripRadioButtonMenuItem radioItem = item as ToolStripRadioButtonMenuItem; if (radioItem != null && radioItem != this && radioItem.Checked) { radioItem.Checked = false; // Only one item can be selected at a time, // so there is no need to continue. return; } } }
private void AddColorsMenu(ToolStripMenuItem menu, C64Color sel) { foreach (ColorDefinition c in Colors.ToArray()) { ToolStripRadioButtonMenuItem item = new ToolStripRadioButtonMenuItem(c.Name); item.Tag = c; if (c.ColorId == sel) { item.Checked = true; } menu.DropDownItems.Add(item); } }