Q:

Toggle between Mdi Children

I have an MDI form in which I create two MDIChild forms, cf1 and cf2. 
I have a button which, when clicked, should toggle the "focus" (i.e. which form is "on top") between cf1 and cf2. 
In the constructor of the MDI parent, I assign the MDIParent of the respective cf1 and cf2.  Then I execute cf1.Show() then cf2.Show(), thus cf2 ends up "on top" or "focused." 
When I press the toggle button the first time, cf1 becomes focused and cf2 becomes inactive. 
Any further attempts to change the z-order after this are unsuccessful. 
I have tried Activate, ActivateMdiChild, TopMost and BringToFront, all without success. 
using System;
using System. Windows. Forms;

namespace MDITest
{
    public partial class Form1 : Form
    {
        private readonly ChildForm cf1 = new ChildForm();
        private readonly ChildForm cf2 = new ChildForm();

        public Form1()
        {
            InitializeComponent();
            cf1.MdiParent = this;
            cf2.MdiParent = this;
            cf1.Text = "Window 1";
            cf2.Text = "Window 2";
            cf1.Show();
            cf2.Show();
        }

        private void Child_WMSize(object sender, EventArgs e)
        {
            LblWindow1State. Text = $"Window 1 - {cf1.WindowState. ToString()}";
            LblWindow2State. Text = $"Window 2 = {cf2.WindowState. ToString()}";
        }

        private void BtnFocus_Click(object sender, EventArgs e)
        {
            //if (ActiveMdiChild == cf1) cf2.Activate();
            //if (ActiveMdiChild == cf2) cf1.Activate();

            //if (ActiveMdiChild == cf1) ActivateMdiChild(cf2);
            //if (ActiveMdiChild == cf2) ActivateMdiChild(cf1);

            //if (ActiveMdiChild == cf1) cf2.TopMost = true;
            //if (ActiveMdiChild == cf2) cf1.TopMost = true;

            if (ActiveMdiChild == cf1) cf2.BringToFront();
            if (ActiveMdiChild == cf2) cf1.BringToFront();
        }
    }
}

The expected result would be to toggle the focus between the two forms as needed.  The actual result is that I can only change from cf2 to cf1, not the other way around. 
I even tried the shotgun approach:
    if (ActiveMdiChild == cf1)
    {
        cf2.BringToFront();
        cf2.Activate();
        ActivateMdiChild(cf2);
        cf2.TopMost = true;
        cf1.TopMost = false;
    }
    if (ActiveMdiChild == cf2)
    {
        cf1.BringToFront();
        cf1.Activate();
        ActivateMdiChild(cf1);
        cf1.TopMost = true;
        cf2.TopMost = false;
    }

With no change in my results. 

A:

You can use the following code to toggle between any number of Mdi children windows:
if (MdiChildren. Length == 0)
    return;
var i = Array. IndexOf(MdiChildren, ActiveMdiChild);
MdiChildren[(MdiChildren. Length + i + 1) % MdiChildren. Length].Activate();

Or
this. Controls. OfType<MdiClient>().First()
    .SelectNextControl(ActiveMdiChild, true,true, true, true);

Or 
SendKeys. SendWait("^{TAB}"); // Control + TAB as well as Control + F6

