Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
665
Set a child ribbon tab on a parent MDI form
posted

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: 

==========================================================================

Dim activeChildManager As UltraToolbarsManager = Me.UltraToolbarsManager1.ActiveMdiChildManager

If Not activeChildManager Is Nothing Then

      Dim childTab As RibbonTab = activeChildManager.Ribbon.Tabs(0)

      Dim parentTab As RibbonTab = childTab.AttachedParentTab

If Not parentTab Is Nothing Then

              Me.UltraToolbarsManager1.Ribbon.SelectedTab = parentTab

Else

End If

========================================================

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

Parents
No Data
Reply
  • 44743
    Verified Answer
    posted

    This is not the recommended location to sync up after an mdi child has been merged. The problem is, hooking this event is the only way the toolbars manager can determine when to merge with the newly active child, and if the toolbars manager happens to hook the event after your code does, your event handler of MdiChildActivate will likely get called before the toolbars manager's event handler. You would be called before the merge, and it looks like that's what's happening here.

    It is instead recommended that you override OnMdiChildActivate in the parent form. Your implementation should call the base implementation first (this will call all event handlers, including the one on the toolbars manager which performs the merge), then it should select the first child tab.

Children