Create an AboutBox : AboutBox : Components C# Source Code


Custom Search

C# Source Code » Components » AboutBox »

 

Create an AboutBox









    



    using System;
    using System.Windows.Forms;
    using System.Drawing;

  public class AboutBox : Form {
    public String Author="navioo";
    public String AppName = "about dialog";
    public String Version = "1.0";

    public AboutBox ()
    {
      InitDialog ();
    }

    private void InitDialog ()
    {
      this.ClientSize = new Size (250, 140);
      this.Text = "About";
      this.FormBorderStyle  = FormBorderStyle.FixedDialog;
      this.ControlBox    = false;
      this.MinimizeBox  = false;
      this.MaximizeBox  = false;

      Button wndClose = new Button ();
      wndClose.Text = "OK";
      wndClose.Location = new Point (90, 100);
      wndClose.Size = new Size (72, 24);
      wndClose.Click += new EventHandler (About_OK);

      Label wndAuthorLabel = new Label ();
      wndAuthorLabel.Text = "Author:";
      wndAuthorLabel.Location = new Point (5, 5);
      wndAuthorLabel.Size = new Size (72, 24);

      Label wndAuthor = new Label ();
      wndAuthor.Text = Author;
      wndAuthor.Location = new Point (80, 5);
      wndAuthor.Size = new Size (80, 24);

      Label wndProdNameLabel = new Label ();
      wndProdNameLabel.Text = "Product:";
      wndProdNameLabel.Location = new Point (5, 30);
      wndProdNameLabel.Size = new Size (72, 24);

      Label wndProdName = new Label ();
      wndProdName.Text = AppName;
      wndProdName.Location = new Point (80, 30);
      wndProdName.Size = new Size (120, 24);

      Label wndVersionLabel = new Label ();
      wndVersionLabel.Text = "Version:";
      wndVersionLabel.Location = new Point (5, 55);
      wndVersionLabel.Size = new Size (72, 24);

      Label wndVersion = new Label ();
      wndVersion.Text = Version;
      wndVersion.Location = new Point (80, 55);
      wndVersion.Size = new Size (72, 24);

      this.Controls.AddRange( new Control [] {
                        wndClose,
                        wndAuthorLabel,
                        wndProdNameLabel,
                        wndVersionLabel,
                        wndAuthor,
                        wndProdName,
                        wndVersion
                        });
      this.StartPosition = FormStartPosition.CenterParent;
      this.ShowDialog ();
    }

    private void About_OK (Object source, EventArgs e)
    {
      Control wndCtrl = ((Button)source).Parent;
      ((Form)wndCtrl).Close ();
    }
    public static void Main(){
      new AboutBox();
    }
  }

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Components
» AboutBox