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:
==========================================================================
If Not activeChildManager Is Nothing Then
Dim parentTab As RibbonTab = childTab.AttachedParentTab
If Not parentTab Is Nothing Then
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
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.
Thanks Mike, but I could use more data. Where should I try this?
Any examples I could look at?
Thanks again,
In your mdi parent form class, add this code:
Protected Overrides Sub OnMdiChildActivate(ByVal e As System.EventArgs) MyBase.OnMdiChildActivate(e)
' Activate the first child ribbon tab in the parent here: ' ...End Sub
Thanks for everything Chris. Your help is a testament to the level of customer care that we've come to expect from Infragistics.
~Matt
Hey Matt.
I am the primary engineer for our toolbars suite, so of course I'll look deeper into the issue with the SelectedTab being different than the tab provided within the EventArgs.
In regards to the FontSize question, normally, we restrict the font size for all tools to be the same within the same parent. However, for the Ribbon, a single font size is enforced across the entire Ribbon. All tool/RibbonGroup related FontSize properties will be ignored. You would have to change the Ribbon's GroupSettings.ToolAppearance.FontData.FontSize for it to take affect. However, this will affect all tools on the Ribbon. If you are looking to only change the FontSize for this one tool, you'll most likely have to switch from using a TextBoxTool to using a ControlContainerTool and assigning an UltraTextEditor as the Control.
I hope this helps.
Chris
Thanks Chris, you've been a tremendous help. Not to be greedy with your time, but while I've got you, a couple of things:
1) By way of completeness, I wanted you to see that the toolbar's selected tab and the tab that is sent in AfterRibbonTabSelected are different any time the selected tab is changed in code. This is evidenced in the attached sample project. Might want to have an engineer look that over.
2) How ON EARTH do I get the font size to change on a TextBoxTool on the ribbon? On the Search tab in the attached project, I've got a text box tool that I am dying to have Comic Sans at 24 points. The InstanceProperties.EditAppearance seems to have allowed me to modify the font family, but not the size. Help?
Glad to hear that you got it working. I'm guessing it is the recursion that causes the ribbon's SelectedTab to be changed again after it fires the AfterRibbonTabSelected for the e.Tab.
Let me know if you need and further assistance.
Hey Chris, I was able to get this sorted. Definitely some oddness here because in the AfterRibbonTabSelected event, the ToolbarsManager.Ribbon.SelectedTab is NOT THE SAME as e.Tab. Anyway, managed to get around this using the below code.
Private Sub tbrMain_AfterRibbonTabSelected(sender As Object, e As Infragistics.Win.UltraWinToolbars.RibbonTabEventArgs) Handles tbrMain.AfterRibbonTabSelected If Not (e.Tab.Key.ToUpper.Contains("HOME") And (Me.tbrMain.Ribbon.SelectedTab IsNot Nothing AndAlso Me.tbrMain.Ribbon.SelectedTab.Key.ToUpper.Contains("MDICHILD"))) Then Me.FiddleWithActiveWindowsBasedOnTabSelection(e.Tab) End If End Sub