RibbonBar - problem to find parent control |
Post Reply |
Author | |
iamgtd
Senior Member Joined: 25 February 2009 Status: Offline Points: 131 |
Post Options
Thanks(0)
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# --------- |
|
chrisABC
Senior Member Joined: 05 June 2008 Status: Offline Points: 258 |
Post Options
Thanks(0)
|
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
|
|
iamgtd
Senior Member Joined: 25 February 2009 Status: Offline Points: 131 |
Post Options
Thanks(0)
|
I'm using the ActiveX version...
|
|
---------
OS: Win 10 64 bit Codejock Version 22.1 ActiveX MS Visual Studio 2022 - C# --------- |
|
chrisABC
Senior Member Joined: 05 June 2008 Status: Offline Points: 258 |
Post Options
Thanks(0)
|
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
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |