Print Page | Close Window

RibbonBar - problem to find parent control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=15552
Printed Date: 06 October 2024 at 4:32pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: RibbonBar - problem to find parent control
Posted By: iamgtd
Subject: RibbonBar - problem to find parent control
Date Posted: 05 November 2009 at 9:44am

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#

---------



Replies:
Posted By: chrisABC
Date Posted: 05 November 2009 at 11:38am
This section of the Forum is for ActiveX components. You should get better answers if you post the question in the Section for C# code.

-------------
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6


Posted By: iamgtd
Date Posted: 05 November 2009 at 11:43am
I'm using the ActiveX version...

-------------
---------

OS: Win 10 64 bit

Codejock Version 22.1 ActiveX

MS Visual Studio 2022 - C#

---------


Posted By: chrisABC
Date Posted: 05 November 2009 at 11:54am
Sorry, I was confused by your C sample code.

I only speak Visual Basic :-)



There is a Section of the Forum for C++, with a sub Forum Command Bars.   Maybe you would get better answer in there.


-------------
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6


Posted By: Oleg
Date Posted: 05 November 2009 at 12:38pm
Hi,
 
You need "ctrl.CommandBar " instead of ctrl.Parent.
but I ерштл better to change code for Update architecture like our samples do - user can copy this control to Quick access and you will have 2 instances for same Id.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net