In a mdiparent form a menustrip is present. when click this menustrip a new form is open.
I want to develop when click the menustrip only one form is open. After open the form if i click the menustrip no form will be open. when that opened form is close by click the close button of the new form the form will close. after close the form when i click the menustrip only one form will open.

When you open the second form also disable the menustrip button.
Attach a method to the new form's FormClosed event that enables the button.
The sample below is for a toolstripbutton but the pattern is the same.

private void toolStripButton1_Click(object sender, EventArgs e)
        {
            toolStripButton1.Enabled = false;
            Form1 frm = new Form1();
            frm.MdiParent = this;
            frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
            frm.Show();
        }

        void frm_FormClosed(object sender, FormClosedEventArgs e)
        {
            toolStripButton1.Enabled = true;
        }

This is just one of many ways that can be used to achieve this.

What you describe is a Singleton; An object which can only have a single instance of itself.
Check the info in the link to see how a singleton can be implemented.
I only point this out for completeness, you can acheive the same result much more simply in your scenario the way nick has shown you.

menustrip is in one form & close button is in another form. how it possible to set the code
toolstripbutton1.Enabled=true;

please help me

in a mdiparent form a menustrip is present. when click the menustrip one form is open which is child form of this mdiparent form.
if the user click the menustrip further no form will be opened if one form is open.

Behind the menustrip button is a button click event handler method that is opening the child form.
In this method add code to disable the menustrip button.
Also, add code to capture the FormClosed event of the new child form (like in my earlier post).
In the same form add the FormClosed event handler method.
In this method you need to enable your menustrip button (not a toolstrip button, that was just in my example code).
This will execute (on the main form) when the child form closes.

You can either attach a child.FormClosing event handler in the parent (see the code in my tutorial here EDIT: OR in nick's post lol..my bad) or you can create a property to access the control and use

this.MdiParent to get a reference to the parent form

...this is covered in another of my tutorials.

Hi Bijaya123,

Here is the Method that i created for Calling open only one form when u click on Menu in MDIParent.
Hope this Method can help you!

usage :
On Even ToolStripMenuItems

Form1 frm1 = new Form1();
CheckActiveChildForm(frm1,"myForm");
//myForm is the Text of Form1

          Cheer...! :D

private void CheckActiveChildForm(Form FormControl, string FormExists)
        {
            int h = 0;

            if (MdiChildren.Count() == 0)
            {
                //Form2 childF = new Form2();
                FormControl.MdiParent = this;
                FormControl.Show();
            }

            if (MdiChildren.Count() > 0)
            {
                for (int i = 0; i < MdiChildren.Count(); i++)
                {

                    if (MdiChildren.ElementAt(i).Text == FormExists)
                    {
                        h = 1;

                    }

                }

            }

            if (h == 0)
            {

                FormControl.MdiParent = this;
                FormControl.Show();
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.