New to Telerik UI for WinForms? Download free 30-day trial

Get a HostWindow by its Content

In certain cases, you may need to perform specific operations depending on the currently activated HostWindow in regards to the form/user control that it contains.

In order to do this, you should first subscribe to the ActiveWindowChanged event and then execute the following code snippet in the ActiveWindowChanged event handler:

void radDock1_ActiveWindowChanged(object sender, Telerik.WinControls.UI.Docking.DockWindowEventArgs e)
{
    HostWindow hostWin = e.DockWindow as HostWindow;
    if (hostWin != null)
    {
        if (hostWin.Content is VegetablesForm)
        {
            // custom implementation here
        }
    }
}

Private Sub radDock1_ActiveWindowChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Docking.DockWindowEventArgs)
    Dim hostWin As HostWindow = TryCast(e.DockWindow, HostWindow)
    If Not hostWin Is Nothing Then
        If TypeOf hostWin.Content Is VegetablesForm Then
            ' custom implementation here
        End If
    End If
End Sub

Getting a HostWindow by its content

In order to get a HostWindow that hosts a particular form/user control instance, you should call the GetHostWindows method passing the contained control as a parameter. Supposing that vegetablesForm is an instance of type VegetablesForm, we can use the following code snippet:

HostWindow vegetablesWindow = this.radDock1.GetHostWindow(vegetablesForm);

Dim vegetablesWindow As HostWindow = Me.RadDock1.GetHostWindow(VegetablesForm)

See Also

In this article