public static void SetAllRibbonButtonsToUncheckedStatus(Ribbon ribbon) { if (ribbon == null || ribbon.Tabs == null || ribbon.Tabs.Count.Equals(0)) { return; } RibbonModulePluginItem modulePluginItem = null; foreach (RibbonTab tab in ribbon.Tabs) { foreach (RibbonPanel panel in tab.Panels) { foreach (RibbonItem item in panel.Items) { modulePluginItem = RibbonModulePluginProvider.GetRibbonModulePluginItem(tab.Name, item.Name); if (modulePluginItem != null && modulePluginItem.ClickStatus == RibbonButtonClickStatus.ToggledCheckedOnClick) { continue; } item.Checked = false; } } } }
public static void SetSingleRibbonButtonToCheckedStatus(Ribbon ribbon, string tabText, string buttonName) { if (ribbon == null || ribbon.Tabs == null || ribbon.Tabs.Count.Equals(0) || string.IsNullOrEmpty(tabText) || string.IsNullOrEmpty(buttonName)) { return; } RibbonModulePluginItem modulePluginItem = null; foreach (RibbonTab tab in ribbon.Tabs) { foreach (RibbonPanel panel in tab.Panels) { foreach (RibbonItem item in panel.Items) { modulePluginItem = RibbonModulePluginProvider.GetRibbonModulePluginItem(tab.Name, item.Name); if (modulePluginItem != null && modulePluginItem.ClickStatus == RibbonButtonClickStatus.ToggledCheckedOnClick) { continue; } item.Checked = tabText.Equals(tab.Text) && buttonName.Equals(item.Name); } } } }