Click here to Skip to main content
11,492,168 members (59,746 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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:
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 3-Oct-12 13:06pm
GB_1114256
Edited 3-Oct-12 14:33pm
v2
Comments
Wes Aday at 4-Oct-12 10:01am
   
Most likely you have your form2 windowstate property set to minimized.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Take three forms

Formmain, Formfirst,Formsecond

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

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();
 
       }
   }
  Permalink  
v3

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 Maciej Los 276
2 Sascha Lefèvre 265
3 Andy Lanng 249
4 F-ES Sitecore 230
0 Sergey Alexandrovich Kryukov 9,829
1 OriginalGriff 8,530
2 Sascha Lefèvre 3,579
3 Maciej Los 3,332
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100