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
        }
    }
}

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);