This is a migrated thread and some comments may be shown as answers.
Determine active child form in MDI app
3 Answers 102 Views
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 2
Tim asked on 13 Aug 2009, 04:10 PM
I am using Dock and RibbonBar (Q2 2009 release) to design a UI. I have the Dock control set to AutoDetectMdiChildren, and can easily add forms as tabbed documents. What I would like to do is change the active RibbonTab based on the active child form in Dock so that the commands match the active document.

I thought this would be relatively easy to do, but I seem to be stuck.
I have implemented an event handler for the ActiveWindowChanged event of the Dock control. I can obviously gain access to the DockWindow via the DockWindowEventArgs parameter. What I haven't been able to do is determine the type of form that the DockWindow represents. Basically what I would like to be able to do is something like this:

if (DockWindow is SettingsForm) 
  // Change to appropriate RadRibbonTab 
else 
 // do something else 

It seems like there should be a way of doing something like this without having to iterate over the MdiChildren array and I would be at all surprised if I am looking at this the wrong way.

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 14 Aug 2009, 09:04 AM
Hi Tim,

When you create and show an MDI child form, a HostWindow is created in RadDock to host the form. The form itself is set as content in the HostWindow. So, the code snippet for the desired scenario will look like this:
void radDock1_ActiveWindowChanged(object sender, DockWindowEventArgs e)  
{  
    if (e.DockWindow is HostWindow)  
    {  
        if (((HostWindow)e.DockWindow).Content is Form2)  
        {  
            // change ribbon tab  
        }  
    }  

I hope this is helpful. If you have additional questions, feel free to contact me.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jonathan Hylton
Top achievements
Rank 1
answered on 12 Jan 2011, 02:17 PM
HI there,

Has the naming of the Hostwindow changed in 2010 SP1? I am having issues when converting this code to VB as this is what I am trying to use:

Private Sub radDock1_ActiveWindowChanged(sender As Object, e As DockWindowEventArgs)
    If TypeOf e.DockWindow Is HostWindow Then
                ' change ribbon tab   
        If TypeOf DirectCast(e.DockWindow, HostWindow).Content Is Form2 Then
        End If
    End If
End Sub

Thanks!

Jonathan
0
Nikolay
Telerik team
answered on 12 Jan 2011, 02:51 PM
Hello Jonathan,

There is no change in the naming of the HostWindow type. Please note, however, that this type is contained in the Telerik.WinControls.UI.Docking namespace, so you need to import it:
Imports Telerik.WinControls.UI.Docking

I hope this helps.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Dock
Asked by
Tim
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Jonathan Hylton
Top achievements
Rank 1
Share this question
or