Hi,
Can you please let me know how I can run two windows form at the beginning of an application which one of them can be something like a "Quick Start" form or "Tip of Day" form and also the main application form which is running at the background and of course is visible but not accessible until the user cancel of finish the outer form?

Thanks for your time in advance

Have your main form, create and load another form. You would show this new form as a dialog box, making it impossible to click on the owner (main) form.

Do it like:

//Program.cs file:
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());// open Form1        
        }
    }
        //form1:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            new Form2().Show(); //open Form2 
        }
    }

Hi Mitja,
Thanks for your reply but I am encountering with following error:

Error 1 Type 'FinalFormLoader.Form1' already defines a member called 'Form1' with the same parameter types c:\users\documents\visual studio 2010\Projects\FinalFormLoader\FinalFormLoader\Form1.cs 14 16 FinalFormLoader

Show me the code you have, otherwise I cannot tell you what can be wrong.
Thx.

Sure,
I have the first form as:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FinalFormLoader
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Form2 foo = new Form2();
            foo.ShowDialog();
        }
    }
}

The second form is:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FinalFormLoader
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
    }
}

and finally the program.cs is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace FinalFormLoader
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

    }
}

I tried to add the

//form1:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            new Form2().Show(); //open Form2 
        }
    }

to the program.cs as you said but I am getting the
Error 1 Type 'FinalFormLoader.Form1' already defines a member called 'Form1' with the same parameter types

Thnaks

This is not the whole code you have. There has to be another one for creating and initializing (or opening) Form1. Thats why you get this error message.

Hi Mitja,

as I said I update the program.cs to

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace FinalFormLoader
{
    //Program.cs file:
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());// open Form1        
        }
    }
    //form1:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            new Form2().Show(); //open Form2 
        }
    }
}

and as when as I run the project I am getting the following error
Error 1 Type 'FinalFormLoader.Form1' already defines a member called 'Form1' with the same parameter types c:\users\documents\visual studio 2010\Projects\FinalFormLoader\FinalFormLoader\Form1.cs 14 16 FinalFormLoader

which refers to first code snippet which I send it to you already but here it is again

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FinalFormLoader
{
    public partial class Form1 : Form
    {
        public [U]Form1()[/U]
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Form2 foo = new Form2();
            foo.ShowDialog();
        }
    }
}

Thanks again

Hi Mitja,

as I said I update the program.cs to

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace FinalFormLoader
{
    //Program.cs file:
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());// open Form1        
        }
    }
    //form1:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            new Form2().Show(); //open Form2 
        }
    }
}

So this whole code is in your program.cs file?? Your code now has two implementations of Form1.
If so, delete what is of form1.

Form1 has its own class and its own code.

Sorry Mitja,
I also have this in Form.Designer.cs

namespace FinalFormLoader
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1301, 546);
            this.Name = "Form1";
            this.Text = "Main";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion
    }
}

Is this what you where asking for?

Hi
Can any one tell me what's wrong with my code?
I just need to create a "Quick Start" form on the top of main application form

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.