none
Multiple Forms each with its own ToolStrip RRS feed

  • Question

  •  

    We have an MDI application of soughts.  Each MDI form has a ToolStrip.  In one sequence of actions the user can end up with 2 MDI forms on screen, Form A and Form B (both with identical tool strips).  Form B is active and focused and is in front of Form A.  When the user holds down ALT as if to access the short cut key of the ToolStrip Form A is brought to the front and focused.

     

    Does anyone know why the ToolStrip on the focused Form B isn't chosen?

     

    A bit of a strange one and non standard behaviour I guess but any help apreciated...

     

    Thanks

     

    Nick

    Friday, May 30, 2008 12:31 PM

Answers

  • Hi Linda

     

    Thanks for the reply.  I've been investigating the issue and it wasn't as I thought.  Another piece of code was attempting to manage focus and setting the focus to another UI element in the application in a certain set of circumstances.  I've just this minute found that code and corrected it and the tool strips are now behaving as expected.

     

    Thanks for your efforts though.

     

    Nick

     

    Monday, June 2, 2008 10:55 AM

All replies

  • Hi Nick,

     

    I performed a test based on your description but didn't reproduce the problem on my side.

     

    In my test, I create a WinForm application project and add Form2 and Form3 in the project. I add a ToolStrip on the Form2 and Form3 respectively. I add a DropDownButton with a ToolStripMenuItem in each of the ToolStrip. The shortcut of the ToolStripMenuItem is Alt+A. In the Click event of the ToolStripMenuItem, I add a line of code to print something:

     

    // in Form2.cs file

    private void itemToolStripMenuItem_Click(object sender, EventArgs e)
     {
                Console.WriteLine("form2 menu item");
     }

    // in Form3.cs file

    private void itemToolStripMenuItem_Click(object sender, EventArgs e)
     {
                Console.WriteLine("form3 menu item");
     }

     

    Set the IsMdiContainer property of the Form1 to true. In the Load event handler of the Form1, open Form2 and Form3:

    // in Form1.cs file

    private void Form1_Load(object sender, EventArgs e)
     {
                Form2 frm = new Form2();
                frm.MdiParent = this;
                frm.Show();
                Form3 frm3 = new Form3();
                frm3.MdiParent = this;
                frm3.Show();
      }

     

    Build and run the application and press Alt+A. "form3 menu item" is printed in the Output window, which indicates the toolstrip item in the Form3 is clicked. Activate the Form2, and press Alt+A, and "form2 menu item" is printed in the Output window.

     

    Is there any difference between your code and mine?

     

    Linda

    Monday, June 2, 2008 8:59 AM
  • Hi Linda

     

    Thanks for the reply.  I've been investigating the issue and it wasn't as I thought.  Another piece of code was attempting to manage focus and setting the focus to another UI element in the application in a certain set of circumstances.  I've just this minute found that code and corrected it and the tool strips are now behaving as expected.

     

    Thanks for your efforts though.

     

    Nick

     

    Monday, June 2, 2008 10:55 AM