Irregular behavior on lost focus from RibbonCombBox

Feb 25, 2016 at 8:13 AM
Hi, I had a problem, but now solved. I hope, someone teach me it is best solution or not.

Ribbon control set on MDI Form. Ribbon control has a RibbonComboBox and a RibbonButton. Some MDI-Child form shown.
like this:
        Form f1 = new Form();
        f1.MdiParent = this;
        f1.Text = "1";

        Form f2 = new Form();
        f2.MdiParent = this;
        f2.Text = "2";

        Form f3 = new Form();
        f3.MdiParent = this;
        f3.Text = "3";

        Form f4 = new Form();
        f4.MdiParent = this;
        f4.Text = "4";
f4 is actived at this point. Next, RibbonComboBox textarea click by mouse and focused.

After this, I tried click on RibbonButton or RibbonTab, then f1 form was actived. I surprised, f1 form was activated.

I checked the source code, and found two place for adjust. I seemed focus on automatically by lost focus on RibbonComboBox. This automatically focus is the first created form. I considered, focus on RibbonComboBox's parent control before RibbonComboBox remove or visible property change to false.

such as:
At RemoveActualTextBox method in RibbonTextBox.cs
     if (_actualTextBox == null || _removingTxt)
     _removingTxt = true;

    if (_actualTextBox.Parent != null)    // Added
        _actualTextBox.Parent.Select();   // Added

    TextBoxText = _actualTextBox.Text;
    _actualTextBox.Visible = false;
At RemoveHelperControls method in Ribbon.cs
        while (Controls.Count > 0)
            Control ctl = Controls[0];

            if(ctl.Parent!=null)   // Added
                ctl.Parent.Select();  //Added

            ctl.Visible = false;


Behavior is fine after modified the code.
Is somebody has other idea?