• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Displaying a form when Main Form of the application is loaded

Hi,

I need to show a preference form when the application is first launched. If I show the preferences form at the Form_Load event of the application main form, the main form is not displayed. I want that the main form is launched then the preferences form is displayed. Any suggestions?

Thanks, Nauman.
0
nauman_ahmed
Asked:
nauman_ahmed
2 Solutions
 
s_sansanwalCommented:
Open form in PAINT event and add a flag

            private bool loaded = false;
            private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
            {
                  if(loaded == false)
                  {
                        Form2 frm = new Form2();
                        frm.ShowDialog();
                        loaded = true;
                  }
            }

Hope this helps.

S Sansanwal
0
 
GrumbleBotCommented:
In the constructor add this after InitializeComponent();

   this.Show(); //display the main form
   Form2 f = new Form2(); //Your preference form
   f.ShowDialog(); // then display your preference form

hope this helps
good luck

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now