MDI Form App

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • visualise01
    New Member
    • Sep 2008
    • 8

    MDI Form App

    I have created a windows app form project.

    I have 3 forms, the first one I have set to be MDI Parent, the other two are Child.

    When I click a button to open the two child forms, how can I stop them from opening more than once.

    As it is just now, the form opens however many time I click the button, but I only want them to open once.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    What I do is make the child forms members of the parent form. Private global variables if you will:
    Code:
    public class Form1 : Form
    {
    private Form2 f2;
    
    public Form1()
    {
    InitializeComponent();
    f2 = new Form2()
    }
    }
    And when I want to show it, I check to see if f2 has been disposed. If it has, I make a new instance and show it, otherwise, I just focus on it.

    Note: I just typed this code in by hand. I didn't copy+paste from an existing project. This is just an example.

    Comment

    Working...