I'm try to get each ribbon tab on child form when its loaded to set the first tab (index 0) so the user would see this tab as the selected tab.
I read the following blog and tried it in VB.net:
>>> Ultratoolbarsmanager: How to programmatically activating a child tab
Here's my code:
==========================================================================
========================================================
But, [activeChildManager] is "Nothing" when I run the code
Note: the above code is located in the parent MDI form "MdiChildActivate" event.
Is the the correct location? (this is where I would like to manage all forms that load)
Have we missed something?
Thanks ahead of time.
Patrick
I managed to make the following C# code in the MDI parent work perfectly. This kind of thing should be in the Infragistics KBase using the keyword "Merge" under UltraWinToolbar. Actually, what would be 100% better is an "AfterMdiChildMerge" event on the toolbar. Overriding a protected Form method is no big deal but to me this shouldn't be done through polymophism so much as event handling.
protected override void OnMdiChildActivate(EventArgs e) { base.OnMdiChildActivate(e); UltraToolbarsManager childToolbarsManager = this.UltraToolbarsManager.ActiveMdiChildManager; if (childToolbarsManager != null) { foreach (RibbonTab ribbonTab in childToolbarsManager.Ribbon.Tabs) { if (ribbonTab.AttachedParentTab != null) { this.UltraToolbarsManager.Ribbon.SelectedTab = ribbonTab.AttachedParentTab; break; } } } }
An event is a good idea. I have forwarded this to post to the DS manager to create a feature request for this on your behalf.
Hi,
I have created a new future request regarding to handle the merge event. Your reference number for this feature request is FR11321.
Our product team chooses new feature requests for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products so as trends appear in requested features, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your feature is chosen for development you will be notified at that time.
Thank you for your request.
Many thanks for creating the request.
- Shaun
I can see that this post is ancient history, I can only hope that someone will see. Using code very similar to the above (exact code shown below) I am getting a NullReferenceException. The exception arises when switching from an MDI child to another instance of the same form as an MDI child (IE, I have two 'Client' forms open that are showing different clients). This works well if I switch from one open client to another MDI child that doesn't have a toolbar manager on it, and then switch to the other client. But when switching from one client to another, the exception arises.
Protected Overrides Sub OnMdiChildActivate(e As EventArgs) MyBase.OnMdiChildActivate(e) 'Exception comes here
If Me.tbrMain.ActiveMdiChildManager IsNot Nothing Then Me.tbrMain.Ribbon.SelectedTab = Me.tbrMain.ActiveMdiChildManager.Ribbon.Tabs(0).AttachedParentTab End If End Sub
Exception is NullReferenceException with the below stack trace.
at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.InternalSetActiveMdiChildManager(UltraToolbarsManager newActiveMdiChildManager, Boolean calledFromMdiChildActivate, Boolean remergeIfUnchanged) at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.OnFormMdiChildActivated(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Form.OnMdiChildActivate(EventArgs e) at ServTrue.frmMain.OnMdiChildActivate(EventArgs e) in D:\Development\Users\Matt\ServTrue\Trunk\ServTrue_Dev\Forms\General\frmMain.vb:line 2768 at System.Windows.Forms.Form.ActivateMdiChildInternal(Form form) at System.Windows.Forms.Form.WmMdiActivate(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks in advance, let me know if I can provide more detailed information.
~Matt