[Solved] Docking Windows positioning

1 Answer 6 Views
Dock
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Carl asked on 18 Mar 2026, 02:39 PM

I'm using the DockWindow on an MDI WinForms app. The Customer Search form is the first one to open.

When I open another form I'd like it to appear to the right of Customer Search. For some reason its appearing to the left.

The code below shows how I open it. Setting the MDIParent adds it to the DocumentWindows collection.

How can I get the Account form to appear to the right of Customer Search. (And any forms opened after that also must appear to the right.)

FormAccount? form = null;
foreach (HostWindow window in this.dock.DockWindows.DocumentWindows)
	if (window.MdiChild is FormAccount)
	{
		FormAccount formCandidate = (FormAccount)window.MdiChild;
		if (formCandidate.BranchId == GlobalServices.Instance.ActiveBranchID && formCandidate.AccountId == (accountId == null ? GlobalServices.Instance.ActiveAccount.NamesId : accountId))
			form = formCandidate;
	}

if (form == null)
{
	form = accountId == null ? new FormAccount(GlobalServices.Instance) : new FormAccount(GlobalServices.Instance, accountId);
	form.AccountId = GlobalServices.Instance.ActiveAccountID;
	form.MdiParent = this;
	form.SetImageAndTitle(ETitleFormat.Account);
	form.AccountFormType = EAccountFormType.Account;
	form.ControlBox = false;
	form.LaunchedFromIPC = launchedFromIPC;
	if (sender == null)
		this.WindowState = FormWindowState.Maximized;
	form.Show();
}

HostWindow hw = App.MainForm.dock.GetHostWindow(form);
if (hw != null)
	dock.ActivateWindow(hw);

Thanks

Carl

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 19 Mar 2026, 01:45 PM

Hi Carl,

Thank you for reaching out to us.

You can try manually changing the position of the DockWindow (HostWindow in your scenario). You can subscribe to the DockWindowAdded event and change the position of the added window in the collection:

private void RadDock1_DockWindowAdded(object sender, DockWindowEventArgs e)
{
    DockTabStrip strip = (DockTabStrip)e.DockWindow.TabStrip;
    SetTabPosition((HostWindow)e.DockWindow);
}
private void SetTabPosition(HostWindow window)
{
    this.radDock1.DockWindowAdded -= RadDock1_DockWindowAdded;
    DockTabStrip tabStrip = (DockTabStrip)window.TabStrip;
    for (int i = 0; i < tabStrip.TabPanels.Count; i++)
    {
        if (tabStrip.TabPanels[i] == window)
        {
            HostWindow item = tabStrip.TabPanels[i] as HostWindow;
            if (item != null)
            {
                tabStrip.TabPanels.RemoveAt(i);
                tabStrip.TabPanels.Add(item);
            }
            break;
        }
    }
    this.radDock1.DockWindowAdded += RadDock1_DockWindowAdded;
}
I hope that this approach will work for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Dock
Asked by
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or