Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi,

I am calling a form1 show function at a menu item click. When the form1 opens, on OK button click, I am opening another form2 using an instance and closing the form1.
But the problem is that when form2 opens and form1 closes, the form2 gets minimized. I dont want that to happen, I even tried disabling the form2 minimized button.

here is a sample of what my code looks like:
C#
MenuItemClick()
{
    Form1 frm1 = new Form1;
    frm1.show();
}
///this displays Form 1

Form1Button_OK_Click()
{
  Form2 frm2 = new Form2();
  frm2.show();
  this.hide();////(Form1)
}


When I do this, the form1 does close, but the form2 minimizes.I want Form2 to be up on the screen. Can anyone help me on this?

Thanks
Posted
Updated 3-Oct-12 13:33pm
v2
Comments
[no name] 4-Oct-12 10:01am    
Most likely you have your form2 windowstate property set to minimized.

1 solution

Take three forms

Formmain, Formfirst,Formsecond

C#
public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
            FormFirst frs = new FormFirst();
            frs.Show();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {

        }
    }


In the Formfirst ok button click write below

C#
public partial class FormFirst : Form
   {
       public FormFirst()
       {
           InitializeComponent();
       }

//Below is the button click of formfirst

       private void button1_Click(object sender, EventArgs e)
       {
           FormSecond fs = new FormSecond ();
           fs.Show();
           this.Hide();

       }
   }
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900