I'm using in a Ribbonbar SplitPopupControls. At the runtime controls are enabled and disabled in dependency of the state of the program. So it could be situation that all child controls of a SplitPopupControl are disabled. In this case I want to disable also the SplitPopupControl itself and vize versa.
Please see the following function for enabling or disabling a CommandBarControl.
The Enabled state of the control is changed and also it's checked if the control is placed in a SplitPopupControl. If yes, then all child controls of the SplitPopupControl are checked for their enabled-property. This is working, my problem is to set the Enabled property of the SplitPopupControl.
Please help me.
private void EnableCommandControl(int commandid, bool enablecommand) { // Find control XtremeCommandBars.CommandBarControl ctrl = RibbonBar().FindControl(null, commandid, null, true);
if (ctrl != null) { // Enable/disable control ctrl.Enabled = enablecommand; if (ctrl.Parent.Type.ToString() == "xtpBarTypePopup") { // ctrl is child of a popup
XtremeCommandBars.CommandBar parentctrl = (XtremeCommandBars.CommandBar)ctrl.Parent; // <--- works, but I'm thinking this isn't the correct approach //XtremeCommandBars.CommandBarControl parentctrl = (XtremeCommandBars.CommandBarControl)ctrl.Parent; // <--- fails, but this would be better because CommandBarControl has an Enabled property.
if (parentctrl != null) { bool isenabled = false;
foreach (XtremeCommandBars.CommandBarControl childctrl in parentctrl.Controls) { // search through all controls of the parentcontrol
if (childctrl.Type.ToString() == "xtpControlButton") { if (childctrl.Enabled) { isenabled = true; break; } } } // here I want to change the Enabled property of SplitPopupControl, but it fails.
parentctrl.Enabled = isenabled; // <---- doesn't work, because the CommandBar hasn't the property "Enabled" } } } }
------------- ---------
OS: Win 10 64 bit
Codejock Version 22.1 ActiveX
MS Visual Studio 2022 - C#
---------
|