0
votes

i am running a windows application. In this application my main form is a MDI Parent form.I have a splash screen which is not a child form.It is the first form.I want after the splash screen has been loaded the main form that is the MDI Parent should appear. i tried MDIParent.Show(). but it says object reference not set to instance of an object. Please help

private void frmsplashscreen_Load(object sender, EventArgs e)
    {

    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        progressBar1.Increment(5);
        if (progressBar1.Value == 100)
        {
            timer1.Stop();
            this.Close();


        }
    }
1
can you show the full code how you tried to open up the MDI form?Karthik

1 Answers

1
votes

Change the program class as following to show MDI form after splash screen is closed.

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        try
        {          

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            frmsplashscreen frmSplash = new frmsplashscreen();
            frmSplash.ShowDialog();

            YourMDIForm frmMDI = new YourMDIForm();
            Application.Run(frmMDI);
        }
        catch (Exception ex)
        {           
            //Log it
            MessageBox.Show(ex.Message);
        }
    }
}