Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - RibbonBar - problem to find parent control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

RibbonBar - problem to find parent control

 Post Reply Post Reply
Author
Message
iamgtd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 February 2009
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote iamgtd Quote  Post ReplyReply Direct Link To This Post Topic: RibbonBar - problem to find parent control
    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#

---------
Back to Top
chrisABC View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 June 2008
Status: Offline
Points: 258
Post Options Post Options   Thanks (0) Thanks(0)   Quote chrisABC Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
iamgtd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 February 2009
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote iamgtd Quote  Post ReplyReply Direct Link To This Post 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#

---------
Back to Top
chrisABC View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 June 2008
Status: Offline
Points: 258
Post Options Post Options   Thanks (0) Thanks(0)   Quote chrisABC Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.

This page was generated in 0.469 seconds.