Add CommandBarControl Before Item
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=10875
Printed Date: 06 January 2026 at 8:46pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Add CommandBarControl Before Item
Posted By: jpbro
Subject: Add CommandBarControl Before Item
Date Posted: 02 June 2008 at 7:55pm
Hi,
I've been trying to add a CommandBarControl before an existing item in a dynamically generated menu...
I have a QuickAccess control set up as follows (this works fine):
Set objQA = mobjRibbonBar.QuickAccessControls.Add(xtpControlSplitButtonPopup, CMD_Print, "Print") objQA.CommandBar.BarID = CMD_Print With objQA.CommandBar.Controls Set objCtrl = .Add(xtpControlLabel, CMD_PrinterDeviceLabel, "Available Printers") Set objCtrl = .Add(xtpControlButton, CMD_PrintSetup, "Print Setup") objCtrl.BeginGroup = True End With
|
Now I want to dynamically populate a list of available printers between the CMD_PrinterDeviceLabel and CMD_PrintSetup controls. I'm using the InitCommandsPopup event to capture when the CMD_Print QA control drop down button has been pressed as follows:
Private Sub CommandBars1_InitCommandsPopup(ByVal CommandBar As XtremeCommandBars.ICommandBar) Dim i As Long Dim objCtrl As CommandBarControl Select Case CommandBar.BarID Case CMD_Print ' Lots of code not shown to show/hide printers dynamically End Select
|
This also works okay, except when I add a printer to the list, it always appears below the CMD_PrintSetup control. I've tried:
CommandBar.Controls.Add xtpControlButton, CMD_PrinterDevice + i, Printers(i).DeviceName, CMD_PrintSetup
|
And
CommandBar.Controls.Add xtpControlButton, CMD_PrinterDevice + i,
Printers(i).DeviceName, CommandBar.FindControl(, CMD_PrintSetup).Index
|
And
CommandBar.Controls.Add xtpControlButton, CMD_PrinterDevice + i,
Printers(i).DeviceName, CommandBar.FindControl(, CMD_PrintSetup)
|
Without success (the printer device names always get added below the CMD_PrintSetup control). Is there a way to accomplish this?
Thanks in advance.
------------- Product: Xtreme SuitePro (ActiveX) version 16.2.6 Platform: Windows XP - SP3
Language: Visual Basic 6.0 SP6
|
Replies:
Posted By: jpbro
Date Posted: 02 June 2008 at 7:59pm
Okay, the magic potion was:
CommandBar.Controls.Add xtpControlButton, CMD_PrinterDevice + i, dictPrinters.KeyByIndex(i), CommandBar.Controls.Count
|
------------- Product: Xtreme SuitePro (ActiveX) version 16.2.6 Platform: Windows XP - SP3
Language: Visual Basic 6.0 SP6
|
|