CommandBars.Controls Collection (9.5.1.0) |
Post Reply |
Author | |||
Anite.DRC
Newbie Joined: 12 November 2004 Location: United Kingdom Status: Offline Points: 2 |
Post Options
Thanks(0)
Posted: 12 November 2004 at 10:04am |
||
Hi all, I'm currently running the eval version of the AX Suite (9.5.1.0) and have been doing preliminary conversion wirk on one of our aexisting applications. Wondering if you can point me in the direction with the following query. The Menu (Abstract)
I am attempting to access the collection of items below the 'Change Item' menu, but I seem to be missing part of my brain.
So far so good, this gets me to the 'Change Item' control. However, by looking at the 'Controls Collection' of this item I am confronted with the following:- 'Open', 'Close', 'Change Item' and 'Exit'. Logically this is quite incorrect, as collection property of an item should not refer to its own siblings. What am I missing? I want to do this:-
Thank you in advance. |
|||
Regards
Dave |
|||
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
||
Dim oCommandBarControl As CommandBarPopup
Set oCommandBarControl = Me.CommandBars.FindControl(, ID_CHANGEITEM, , True) Call oCommandBarControl.CommandBar.Controls.DeleteAll Collection is the collection of controls the the current control belongs to, so Open, Close, Change Item, and Exit are all in the "File" controls commandbar.controls collection. So oCommandBarControl.Controls will retreive all the sibling controls to the current control. Edited by SuperMario |
|||
Anite.DRC
Newbie Joined: 12 November 2004 Location: United Kingdom Status: Offline Points: 2 |
Post Options
Thanks(0)
|
||
@SuperMario Thanks for that SM, I would not have thought to get to the collection via that route, the hierachy of the CommandBars is a little different than existing collection based controls we have in our applications at present. The example has saved me an immense amount of time, I thank you. |
|||
Regards
Dave |
|||
Gutauckis
Newbie Joined: 06 December 2004 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
||
I have tried the above code in my app as i am trying to do the same thing but it does not work.
At app startup I create the following: Set ControlEdit = frmMain.CommandBars.ActiveMenuBar.Controls.Add(xtpControl Pop up, 0, "&Edit", -1, False) With ControlEdit.CommandBar.Controls Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_UNDO, "&Undo", -1, False) & ;nbs p; Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_UNDO, "Nothing to Undo", -1, False Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_REDO, "&Redo", -1, False) & ;nbs p; Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_REDO, "Nothing to Redo", -1, False Set Control = .Add(xtpControlButton, ID_EDIT_CUT, "Cu&t", -1, False) Control.BeginGroup = True .Add xtpControlButton, ID_EDIT_COPY, "&Copy", -1, False .Add xtpControlButton, ID_EDIT_PASTE, "&Paste", -1, False .Add xtpControlButton, ID_EDIT_PASTENEWIMAGE, "Paste as &New Image", -1, False End With I need to get access to the Undo and Redo popup menu items to add and delete items on the fly. When I try to: Dim oCommandBarControl As CommandBarPopup Set oCommandBarControl = Me.CommandBars.FindControl(, ID_EDIT_MENU_UNDO, , True) Call oCommandBarControl.CommandBar.Controls.DeleteAll The set returns Nothing I have tried a number of things but nothing is working. I notice when the app is starting up and I am creating the items they do not contain the ID I am assigning them. However my execute code works on all my controls so I am assuming the ID is set later in the startup.... Any help would be appreciated. I am using Xtreme Suite. Edited by Gutauckis |
|||
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
||
Manually set the Id for popup controls:
Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_UNDO, "&Undo", -1, False) Control.Id = ID_EDIT_MENU_UNDO Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_UNDO, "Nothing to Undo", -1, False Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_REDO, "&Redo", -1, False) Control.Id = ID_EDIT_MENU_REDO Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_REDO, "Nothing to Redo", -1, False |
|||
Gutauckis
Newbie Joined: 06 December 2004 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
||
I am guessing I don't have to tell you how annoying your answer is. Yes that worked.
Was there something in the documentation that I missed telling me that passing the Id of the control in the .add method does nothing that you have to subsequently set the id after creation? |
|||
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
||
Annoying? .....Anyway, I believe it is documented in one of the
tutorials. The help documentation is in the process of a major
rework over the next few releases. You must only do this for
popup controls.
|
|||
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 |