locked
ACTIVATING MDI CHILD RRS feed

  • Question

  • In a MDI environment let 'view' be an MdiChild.

    I tried: ActivateMdiChild(view) - does not work

    Instead both view.Select() and view.Activate() work, and I do not see any difference between the two.

    Can anybody shed some light?

    Saturday, November 28, 2020 8:11 AM

Answers

  • Hi GiorgioITA,

    Thank you for posting here.

    According to your description, I try to make a test, but I need more information.

    >>let 'view' be an MdiChild.

    Could you provide more details about 'view' and share some related code here? It will help us reproduce your problem.

    Best Regards,

    Xingyu Zhao


    Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).

    • Marked as answer by GiorgioITA Monday, November 30, 2020 10:08 AM
    Monday, November 30, 2020 8:14 AM

All replies

  • Hi GiorgioITA,

    Thank you for posting here.

    According to your description, I try to make a test, but I need more information.

    >>let 'view' be an MdiChild.

    Could you provide more details about 'view' and share some related code here? It will help us reproduce your problem.

    Best Regards,

    Xingyu Zhao


    Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).

    • Marked as answer by GiorgioITA Monday, November 30, 2020 10:08 AM
    Monday, November 30, 2020 8:14 AM
  • mmm... Here is a snippet from a little test program:

        public partial class MainMdi : Form
        {
            public MainMdi()
            {
                InitializeComponent();
                view2 = null;
            }

            private View2 view2;

            private void view2ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                view2 = new View2();
                view2.MdiParent = this;
                view2.Show();
            }

            private void activateToolStripMenuItem_Click(object sender, EventArgs e)
            {
                if (view2 != null) ActivateMdiChild(view2);
            }
        }

    (there are other View1, etc. that the program may open)

    However, in this little program it works! In my actual project a similar code does NOT, and I now found that it works by adding the following in View2:

            private void View2_Activated(object sender, EventArgs e)
            {
                this.BringToFront();
            }

    So, from the point of view of my project the issue is fixed - it remains a mystery for me to understand why I have different behavior in the actual project vs. the testing one.

    Thanks


    • Edited by GiorgioITA Monday, November 30, 2020 10:09 AM
    Monday, November 30, 2020 10:08 AM