Create an About form

How to programmatically create an About form and have it appear centered in a 1000x700 pixel MainForm:

            about = new Form();
        about.MaximizeBox = false;
        about.FormBorderStyle = FormBorderStyle.None;
        about.Size = new Size(400,300);
        about.TopMost = true;           

        Label lblAbout = new Label();
        lblAbout.Text = "About";
        lblAbout.Font = new Font("Verdana",14);
        lblAbout.AutoSize = true;
        int lblAboutLeft = (about.Width - lblAbout.Width)/2;            
        lblAbout.Left = about.Left + lblAboutLeft + 9;
        about.Controls.Add(lblAbout);

        Button btnClose = new Button();
        btnClose.Text = "&Close";           
        btnClose.Width = 50;
        btnClose.Location = new Point(btnClose.Left + 347, btnClose.Top + 275);
        about.Controls.Add(btnClose);

        PictureBox picProgrammer = new PictureBox();
        picProgrammer.AutoSize = true;          
        picProgrammer.Image = Image.FromFile(".\\Resources\\Images\\bryanCircle.PNG");
        about.Controls.Add(picProgrammer);
        picProgrammer.Left += 2;
        picProgrammer.Top += 2;

        TextBox tb = new TextBox();
        tb.Font = new Font("Verdana",10);
        tb.Multiline = true;
        tb.ScrollBars = ScrollBars.Vertical;
        tb.Height = about.Height - lblAbout.Height - btnClose.Height  - 7;
        tb.Width = about.Width - picProgrammer.Width - 8;
        about.Controls.Add(tb);
        tb.Top = lblAbout.Top + lblAbout.Height + 2;
        tb.Left = picProgrammer.Left + picProgrammer.Width;
        string readData = File.ReadAllText(".\\Resources\\Texts\\about.txt");
        tb.Text = readData;

        about.Show();
        int left = (this.Width - about.Width)/2;
        left += iMainFormLeft;
        int top = (this.Height - about.Height)/2;
        top += iMainFormTop;
        about.Location = new Point(left, top);


        btnClose.Click += new EventHandler(btnClose_Click);

Author: kyrathasoft

The only programmer in Glens Fork, Ky.