![]() |
Disable Ribbonbar Buttons |
Post Reply ![]() |
Author | |
jcollier ![]() Senior Member ![]() Joined: 15 February 2006 Status: Offline Points: 250 |
![]() ![]() ![]() ![]() ![]() Posted: 29 March 2006 at 3:42pm |
I am trying to enable/disable ribbonbar buttons at runtime.
I've added the button as such: Set ControlRibbonButton = GroupBatches.Add(xtpControlButton, 0, "Close Batch", -1, False) ControlRibbonButton.Id = ID_CLOSEBATCH Then later, in a subroutine I try: Set ControlRibbonButton = CommandBars.FindControl(, ID_CLOSEBATCH, , True) ControlRibbonButton.Enabled = CanClick I get no buttons returned. I've checked the posts here and tried many different ways but can't seem to get it. Help? |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
Strange, can you post your entire ribbon code so I can see where this button is located?
|
|
![]() |
|
jcollier ![]() Senior Member ![]() Joined: 15 February 2006 Status: Offline Points: 250 |
![]() ![]() ![]() ![]() ![]() |
Yep. It's kinda big but here it is.
Private Sub SetUpRibbonBar() 'On Error Resume Next Dim tabBatches As RibbonTab Dim tabHome As RibbonTab Dim tabContainer As RibbonTab Dim tabTimers As RibbonTab Dim tabAdmin As RibbonTab Dim tabProjects As RibbonTab Dim RibbonBar As RibbonBar Dim GroupBatches As RibbonGroup Dim GroupHome As RibbonGroup Dim GroupContainer As RibbonGroup Dim GroupTimers As RibbonGroup Dim GroupAdmin As RibbonGroup Dim GroupProjects As RibbonGroup Dim ControlRibbonButton As CommandBarControl Dim ControlRibbonPopup As CommandBarPopup Dim ControlShowHide As CommandBarControl Set RibbonBar = CommandBars.AddRibbonBar("MainRibbon") RibbonBar.EnableDocking xtpFlagStretched Set ControlShowHide = RibbonBar.Controls.Add(xtpControlButton, ID_HIDE, "Hide") ControlShowHide.Flags = xtpFlagRightAlign Set ControlShowHide = RibbonBar.Controls.Add(xtpControlButton, ID_SHOW, "Show") ControlShowHide.Flags = xtpFlagRightAlign Set tabHome = RibbonBar.InsertTab(1000, "Home") Set GroupHome = tabHome.Groups.AddGroup("Messages") Set ControlRibbonButton = GroupHome.Add(xtpControlButton, ID_MYMESSAGES, "My Messages") Set ControlRibbonButton = GroupHome.Add(xtpControlButton, ID_COMPOSEMESSAGE, "Compose Message") Set GroupHome = tabHome.Groups.AddGroup("Go To...") Set ControlRibbonButton = GroupHome.Add(xtpControlButton, ID_FINDCONTAINER, "Find Container") Set ControlRibbonButton = GroupHome.Add(xtpControlSplitButtonPopup, ID_RECENTBATCHES, "Recent Batches") Set GroupHome = tabHome.Groups.AddGroup("Quick Links") GroupHome.Add xtpControlButton, ID_LOCALSETTINGS, "Local Settings" GroupHome.Add xtpControlButton, ID_CHANGEPASSWORD, "Change Password" GroupHome.Add xtpControlButton, ID_QUOTEOFTHEDAY, "Quote of the Day" GroupHome.Add xtpControlButton, ID_PROCEDURES, "Procedures" GroupHome.Add xtpControlButton, ID_HOTKEYS, "Hot Keys" GroupHome.Add xtpControlButton, ID_SUGGESTIONS, "Suggestions" GroupHome.Add xtpControlButton, ID_HELP, "Help" GroupHome.Add xtpControlButton, ID_ABOUT, "About" GroupHome.Add xtpControlButton, ID_EXIT, "Exit" Set GroupHome = tabHome.Groups.AddGroup("Time") GroupHome.Add xtpControlButton, ID_TIMESHEET, "Time Sheet" GroupHome.Add xtpControlButton, ID_REVIEWCHANGEREQUESTS, "Review Change Requests" GroupHome.Add xtpControlButton, ID_VIEWPAYROLLHOURS, "View Payroll Hours" GroupHome.Add xtpControlButton, ID_REQUESTCHANGE, "Request Change" Set tabBatches = RibbonBar.InsertTab(1001, "Batches") Set GroupBatches = tabBatches.Groups.AddGroup("Batch") GroupBatches.Add xtpControlButton, ID_CREATEBATCH, "Create Batch" GroupBatches.Add xtpControlButton, ID_CREATEIMAGELESSBATCH, "Create Imageless Batch" Set ControlRibbonButton = GroupBatches.Add(xtpControlButton, 0, "Close Batch", -1, False) ControlRibbonButton.Id = ID_CLOSEBATCH GroupBatches.Add xtpControlButton, ID_IMPORTIMAGES, "Import Images" GroupBatches.Add xtpControlButton, ID_SCANPAGES, "Scan Pages" GroupBatches.Add xtpControlButton, ID_INDEXBATCH, "Index Batch" GroupBatches.Add xtpControlButton, ID_EXPORTBATCH, "Export Batch" GroupBatches.Add xtpControlButton, ID_FIELDDEFINITIONS, "Field Definitions" GroupBatches.Add xtpControlButton, ID_CONTAINERNOTE, "Notes" GroupBatches.Add xtpControlButton, ID_DRAWERS, "Drawers" Set GroupBatches = tabBatches.Groups.AddGroup("Batch Functions") GroupBatches.Add xtpControlButton, ID_AUTOINDEX, "Auto Index" GroupBatches.Add xtpControlButton, ID_DOCUMENTBREAKS, "Document Breaks" GroupBatches.Add xtpControlButton, ID_CUSTOMSQLQUERY, "Custom SQL Query" GroupBatches.Add xtpControlButton, ID_CHECKSEQUENTIALS, "Check Sequentials" 'Set GroupBatches = tabBatches.Groups.AddGroup("Queues") 'Set ControlRibbonButton = GroupBatches.Add(xtpControlSplitButtonPopup, ID_QUEUES, "Queues") Set tabContainer = RibbonBar.InsertTab(1002, "Containers") Set GroupContainer = tabContainer.Groups.AddGroup("Container Queues") GroupContainer.Add xtpControlButton, ID_INPREPRODUCTION, "In Pre-Production" GroupContainer.Add xtpControlButton, ID_INPRODUCTION, "In Production" GroupContainer.Add xtpControlButton, ID_INBILLING, "In Billing" GroupContainer.Add xtpControlButton, ID_INDELIVERY, "In Delivery" GroupContainer.Add xtpControlButton, ID_INACTIVE, "Inactive" GroupContainer.Add xtpControlButton, ID_CUSTOMERREWORK, "Customer Rework" GroupContainer.Add xtpControlButton, ID_VENDORREWORK, "Vendor Rework" Set GroupContainer = tabContainer.Groups.AddGroup("Container Functions") Set ControlRibbonButton = GroupContainer.Add(xtpControlButton, ID_ADDCONTAINER, "Add Container") Set ControlRibbonButton = GroupContainer.Add(xtpControlComboBox, ID_FILTERCONTAINERLIST, "Filter") ControlRibbonButton.Width = 200 ControlRibbonButton.DropDownListStyle = False ControlRibbonButton.AddItem "Container Filter..." ControlRibbonButton.AddItem "Find Unbilled Containers Due Today" ControlRibbonButton.AddItem "Find Unbilled Containers Past Due" ControlRibbonButton.AddItem "Find Unbilled Containers Not Past Due" ControlRibbonButton.ListIndex = 1 Set tabProjects = RibbonBar.InsertTab(1005, "Projects") Set GroupProjects = tabProjects.Groups.AddGroup("Projects") GroupProjects.Add xtpControlButton, ID_VIEWPROJECTINFO16, "View Project Info" GroupProjects.Add xtpControlButton, ID_ADMINPROJECTINFO16, "Admin Project Info" Set tabTimers = RibbonBar.InsertTab(1003, "Timers") Set GroupTimers = tabTimers.Groups.AddGroup("Timer Queues") GroupTimers.Add xtpControlButton, ID_ENHANCEQUEUE, "Enhance Queue" GroupTimers.Add xtpControlButton, ID_BARCODEQUEUE, "Barcode Queue" GroupTimers.Add xtpControlButton, ID_IMPORTQUEUE, "Import Queue" Set GroupTimers = tabTimers.Groups.AddGroup("Timer Servers") GroupTimers.Add xtpControlButton, ID_ENHANCESERVER, "Enhance Server" GroupTimers.Add xtpControlButton, ID_BARCODESERVER, "Barcode Server" GroupTimers.Add xtpControlButton, ID_IMPORTSERVER, "Import Server" Set tabAdmin = RibbonBar.InsertTab(1004, "Admin") Set GroupAdmin = tabAdmin.Groups.AddGroup("Autofill") GroupAdmin.Add xtpControlButton, ID_IMPORTAUTOFILLDATA, "Import Autofill Data" Set GroupAdmin = tabAdmin.Groups.AddGroup("Configuration") GroupAdmin.Add xtpControlButton, ID_USERADMIN, "User Admin" GroupAdmin.Add xtpControlButton, ID_PROCESSADMIN, "Process Admin" GroupAdmin.Add xtpControlButton, ID_DEPARTMENTADMIN, "Department Admin" GroupAdmin.Add xtpControlButton, ID_EMPLOYEETYPES16, "Employee Types" GroupAdmin.Add xtpControlButton, ID_LOCATIONS16, "Locations" GroupAdmin.Add xtpControlButton, ID_ALERTSUPERVISORLIST16, "Alert Supervisor List" GroupAdmin.Add xtpControlButton, ID_DAYOFFREQUESTTYPES16, "Day Off Request Types" GroupAdmin.Add xtpControlButton, ID_BREAKSETTINGS16, "Break Settings" 'add a blank button here for spacing Set ControlRibbonButton = GroupContainer.Add(xtpControlButton, 0, "") Set ControlRibbonButton = GroupContainer.Add(xtpControlButton, ID_SHOWALLOTTEDTIME, "Show Allotted Time") ControlRibbonButton.Parameter = True tabHome.Selected = True End Sub Public Sub SetButtons(Optional CanClick As Boolean = False, Optional bLoggedIn As Boolean = True) On Error GoTo handler Dim ControlRibbonButton As CommandBarControl Set ControlRibbonButton = CommandBars.FindControl(, ID_CLOSEBATCH, , True) ControlRibbonButton.Enabled = CanClick End Sub |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
Ok, I see. Internally the only controls that are in the CommandBar are the controls currently visible in the selected tab and and popups that might be at the same level as the tab buttons (File menu in sample). When a new tab becomes selected, the controls from the old tab are removed and the new tab controls are added.
As a better solution, use the Update event to enable\disable commands. ... Case ID_CLOSEBATCH: Control.Enabled = CanClick ... |
|
![]() |
|
jcollier ![]() Senior Member ![]() Joined: 15 February 2006 Status: Offline Points: 250 |
![]() ![]() ![]() ![]() ![]() |
Ok. I'll see what I can do. Is this going to be "fixed" in the Release?
Speaking of release, is the Release Candidate out yet? |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
Not sure on the RC, but the release is still on for the end of the first week of April.
|
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
Ok, we have fixed this so now it will search all items, not just visible ones
![]() ![]() |
|
![]() |
|
jcollier ![]() Senior Member ![]() Joined: 15 February 2006 Status: Offline Points: 250 |
![]() ![]() ![]() ![]() ![]() |
Fantastic! Can't wait to try it.
|
|
![]() |
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 |