private void OnComponentRemoving(object sender, ComponentEventArgs e) { // If our cluster is being removed if (e.Component == _ribbonCluster) { // Need access to host in order to delete a component IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); // We need to remove all items from the cluster for (int j = _ribbonCluster.Items.Count - 1; j >= 0; j--) { if (_ribbonCluster.Items[j] is IRibbonGroupItem item) { _ribbonCluster.Items.Remove(item); host.DestroyComponent(item as Component); } else { IRibbonGroupContainer container = _ribbonCluster.Items[j] as IRibbonGroupContainer; _ribbonCluster.Items.Remove(container); host.DestroyComponent(container as Component); } } } }
private void AutoUpdateContainer(IRibbonGroupContainer Container) { // Process each component inside the container foreach (Component component in Container.GetChildComponents()) { // If the component is itself a container... if (component is IRibbonGroupContainer) { AutoUpdateContainer(component as IRibbonGroupContainer); } else { // If this is another radio button... if (component is KryptonRibbonGroupRadioButton) { KryptonRibbonGroupRadioButton radioButton = (KryptonRibbonGroupRadioButton)component; // Do not process ourself! if (radioButton != this) { // If the target is checked and allowed to be auto unchecked if (radioButton.AutoCheck && radioButton.Checked) { radioButton.Checked = false; } } } } } }
private void AutoUpdateContainer(IRibbonGroupContainer Container) { // Process each component inside the container foreach (Component component in Container.GetChildComponents()) { // If the component is itself a container... if (component is IRibbonGroupContainer) AutoUpdateContainer(component as IRibbonGroupContainer); else { // If this is another radio button... if (component is KryptonRibbonGroupRadioButton) { KryptonRibbonGroupRadioButton radioButton = (KryptonRibbonGroupRadioButton)component; // Do not process ourself! if (radioButton != this) { // If the target is checked and allowed to be auto unchecked if (radioButton.AutoCheck && radioButton.Checked) radioButton.Checked = false; } } } } }