How would I be able to make a child form come to front on a button click?

How would I be able to make a child form come to front on a button click?

Trick.

private void button1_Click(object sender, EventArgs e)
        {
            Form2 s = new Form2();
            s.MdiParent = this;
            button1.SendToBack();
            s.Show();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.MdiChildActivate += new EventHandler(Form1_MdiChildActivate);
        }

        void Form1_MdiChildActivate(object sender, EventArgs e)
        {
            bool b = MdiChildren.Any((p) =>
                {

                    return p.Visible;
                });

            if (!b)
                button1.BringToFront();
        }

I dont need the button to disappear, since when I made my form MDIParent it turned my form backcolor to a unpleasent color, so I put a picture box with the color I want as the backcolor, and the childforms dont come up in front of the picturebox.

A summary of what I need to do, bring a child form in front of a picture box.

Ok, I made my own code,but I include me changing my start up form(Form1()) to Form1(Form8 F). As a conclusion to that, it made a error in my program.cs

The error

Error	1	'iUltimate.Form1' does not contain a constructor that takes '0' arguments	C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\iUltimate\iUltimate\Program.cs	18	29	iUltimate

Any suggestions?

Pass "null" as an argument.

Edit Program.cs:

Application.Run([B]new Form1(null)[/B]);

And before assigning the "F" variable, check if its not a null:

if (F != null)
  form8 = F;

Thanks

Say I had another form that needs to retrieve data from form1, how would I do that?

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.