By Pavel Tsekov
A class, representing ABOUT form in C#. Use it in your projects.
Here is an example of how we can make an ABOUT form.
To use the class in your projects, you can write the following lines, somewhere in your code:
fAbout frmAbout=new fAbout;
frmAbout.ShowDialog();
So the about form will show itself modally in the center of the screen. Change some of the text things in the fAbout class to make it usable for you.
Here is the class itself :
// Here is an example of an ABOUT form class
// If you want to use it, just put it info you project
using System;
using System.Windows.Forms;
using System.Drawing; //this is included because of the ContentAlignment enumeration
class fAbout : Form
{
private string[] strLines=new string[4]
{"Made by Pavel Tsekov.",
"I've just graduated from the",
"Technical University in Varna (Bulgaria)",
"Thank you for reading this!"};
//we have these three controls on the form
private Button btnOK;
private Label lblPhones;
private RichTextBox rtbInfo;
//fAbout() -> the form's only constructor
public fAbout()
{
//Do some form settings
this.Text="About";
this.StartPosition=FormStartPosition.CenterScreen;
this.FormBorderStyle=FormBorderStyle.FixedDialog;
this.ControlBox=false;
//set the Button control here
btnOK=new Button();
btnOK.Text="OK";
btnOK.Left=this.ClientRectangle.Width-btnOK.Width-10;
btnOK.Top=this.ClientRectangle.Height-btnOK.Height-10;
btnOK.Visible=true;
//let's tie the handler procedure to the event Click of the button
btnOK.Click+=new EventHandler(btnOK_Click);
this.Controls.Add(btnOK);
//set the Label control here
lblPhones=new Label();
lblPhones.Left=0;
lblPhones.Width=this.Width;
lblPhones.Top=this.Height/6;
lblPhones.Font=new Font(lblPhones.Font,FontStyle.Bold);
lblPhones.TextAlign=ContentAlignment.MiddleCenter;
lblPhones.Text="P H O N E S";
lblPhones.Visible=true;
this.Controls.Add(lblPhones);
//set the RichTextBox control here
rtbInfo=new RichTextBox();
rtbInfo.Left=20;
rtbInfo.Top=this.Height/3;
rtbInfo.Width=this.Width-40;
rtbInfo.Lines=strLines;
rtbInfo.ReadOnly=true;
rtbInfo.Visible=true;
this.Controls.Add(rtbInfo);
}
//a Button Click Event handler procedure
private void btnOK_Click(object sender,EventArgs eArgs)
{
this.Close();
}
public static void Main()
{
Application.Run(new fAbout());
}
}