In Microsoft Office 2010, you can attach the Print Preview button to the QAT and when clicked, focus is automatically switched to the Print object under the File tab. I want to be able to emulate this process in an MDI application. Is this possible? I have a ribbon tool on the application menu (2010) which is a popup control container, showing a crystal report, and this works well.
Hello,
In order to achieve this, you can call the DropDown() method on the UltraToolbarsManager.Ribbon.Application2010, and pass the PopupTool you want to be active. In your case, the PopupControlContainerTool containing the Crystal Report.
I've attached a sample solution that demonstrates the functionality. If you click the file menu button, you will notice the ApplicationMenu2010 is opened with PopupMenuTool1 active; but if you click the tool on the QuickAccessToolbar, it will open the ApplicationMenu2010 with the Print PopupMenuTool active.
Let me know if you have any further questions. Thanks,
Chris
Hi Chris, thank you for your quick response and sample project.
I usually develop with VB, but I was able to load your project, run it and see it work perfectly. I'm not familiar enough with C# to convert it to an MDI project, so I've attached a VB sample project.
I believe I have added the appropriate code to replicate what you did in yours, but it doesn't seem to work the same way. On both the parent and child forms, focus switches to the File tab, but doesn't seem to give the correct tool focus. Perhaps you could tell me what I've missed or where I'm going wrong.
Best regards
Julie
Hi Julie.
I took a look at your code. The issue is that you are passing a root tool (i.e. from the Tools collection off of the UltraToolbarsManager), instead of the instance tool from the ApplicationMenu2010.NavigationMenu's Tools collection. It is possible for there to be multiple instances of the same tool within a Tools collection, so we require the actual instance tool to be set as the ActiveContentTool.
Try changing your code to:
Me.UltraToolbarsManager1.Ribbon.ApplicationMenu2010.DropDown(CType(Me.UltraToolbarsManager1.Ribbon.ApplicationMenu2010.NavigationMenu.Tools("Print"), Infragistics.Win.UltraWinToolbars.PopupToolBase))
If you'd like a better explanation of Root and Instance Tools in the UltraToolbarsManager, you can take a look at this help topic and feel free to asks us any questions.
Hi Chris
Thanks for your guidance. I changed the code as suggested, and yes, it works perfectly.
Now, you probably knew there would be a but coming. When I tried to implement this methodology in my project, I'm encountering errors :
Unable to cast object of type MdiMergePlaceHolderTool to PopupToolbase
or words to that effect.
What I can see from my target project, is that the ribbon's are merged, I set MergeOrder on a number of tools so that the parent menu options are visible on the child forms (i.e. Help, Exit etc). I can't seem to merge the ribbon on the test project, or more accurately, I can't remember what setting allows me to do this as most of my projects are created based on custom templates created over a number of years. I thought it was Enable Office 2007 UI, but it must be something else that I've now forgotten. Any further guidance would be appreciated.
Alright, so merging adds a little more complexity. The ToolClick event should be firing on the owning UltraToolbarsManager, in this case, it would fire on the manager on the child form. As such, you need to utilize the MdiParentManager property on the UltraToolbarsManager and open the ApplicationMenu2010 on the parent form.
Select Case e.Tool.Key Case "ShowPrint" ' ButtonTool ' Place code here If Me.UltraToolbarsManager1.MdiParentManager Is Nothing Then Me.UltraToolbarsManager1.Ribbon.ApplicationMenu2010.DropDown(CType(Me.UltraToolbarsManager1.Ribbon.ApplicationMenu2010.NavigationMenu.Tools("Print"), Infragistics.Win.UltraWinToolbars.PopupToolBase)) Else Me.UltraToolbarsManager1.MdiParentManager.Ribbon.ApplicationMenu2010.DropDown(CType(Me.UltraToolbarsManager1.Ribbon.ApplicationMenu2010.NavigationMenu.Tools("Print"), Infragistics.Win.UltraWinToolbars.PopupToolBase)) End If End Select
As far as creating a mdi child for in the sample application, you simply need to set the MdiParent property on the child form prior to calling Show(). The UltraToolbarsManagers will take care of the Ribbon merging automatically.
I've modified and attached your sample to work as an MDI application.
Thanks again Chris, for all your efforts.
I've downloaded the modified project, tested it, and yep, works perfectly .... now we're cooking.
I'm about to leave the office for the day (week), but I look forward to implementing the changes in my development project on Monday.
Best regards and thanks again.