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,
Hello Matt,
Offhand I don't see anything within your code that would cause this exception to occur. It seems like the exception is happening once it goes into the base OnMdiChildActivate() call. Does the problem still occur if you comment out your override of the OnMdiChildActivate()?
I looked through our InternalSetActiveMdiChildManager() method, and nothing obvious jumps out to me in regards to a NullReferenceException being thrown. Additionally, I attempted to reproduce the problem, but was unsuccessful. My guess is there is something specific to the setup of your application that triggers the issue. I've attached my sample to this post. When you have the opportunity, see if you can reproduce the exception with my sample. Please make any changes necessary to the sample to match your application that will help in the reproduction of the problem.
Hopefully we can find a resolution for you quickly.
Chris
Well Chris, I pulled down your sample and copied over my exact toolbar setups and was not able to reproduce. I've clearly got something happening somewhere else in the code. I'll keep poking at it. Thanks for your help.
Hi Matt,
If you narrow down the cause of the issue with your application, please let me know. Hopefully we can add a fix for this scenario within our controls to avoid this issue in the future.
Additionally, if you have any other questions, feel free to ask.
Thanks,
Thanks Chris. I have some stuff happening in the AfterRibbonTabSelected event - when I comment that out, I do not experience the issue. (Of course, then the application doesn't function as expected). When I figure it out, I will come back and post.
OK. I brought in some code very similar to what we are using in the app and I was able to replicate the exception. In fact, it happens immediately upon starting the application. I'm still clueless as to what is actually causing this, but I found that if certain bits are commented out, the exception does not arise. I believe it is somehow related to the fact that the Home tab (the first tab on the parent ribbon) is always selected before the tab hosting the child tab is selected.
I've notated the attachment. I upgraded this project to 2014.2 FYI.
Please let me know what you are able to discover.
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.
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