Displaying the form in center in c#
<p>i am new here, actually i am working on project which is in c#, and in that project i want to display my form in the center of the screen... So for that i have written the following code..</p>

<pre><code>public class CenterForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components;

public CenterForm()
{
    InitializeComponent();
    CenterToScreen();
}

protected override void Dispose(bool disposing)
{
    if (disposing)
    {
        if (components != null)
        {
            components.Dispose();
        }
    }
    base.Dispose(disposing);
}

private void InitializeComponent()
{
    this.button1 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(107, 177);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(75, 23);
    this.button1.TabIndex = 0;
    this.button1.Text = "Ok";
    this.button1.UseVisualStyleBackColor = true;
    // 
    // CenterForm
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.Add(this.button1);
    this.Name = "CenterForm";
    this.Text = "DataGridExample";
    this.Paint += new System.Windows.Forms.PaintEventHandler(this.CenterForm_Paint);
    this.Resize += new System.EventHandler(this.CenterForm_Resize);
    this.ResumeLayout(false);

}
[STAThread]
static void Main()
{
    Application.Run(new CenterForm());
}
private void CenterForm_Resize(object sender, System.EventArgs e)
{
    Invalidate();
    Console.WriteLine("Resize");
}
private void CenterForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
    Graphics g = e.Graphics;
    g.DrawString("Text",
      new Font("Times New Roman", 20),
      new SolidBrush(Color.Black),
      this.DisplayRectangle);
}

private Button button1;
}  
</code></pre>

<p>but it is giving some errors,that are
1)Error 1   'center.Form1.Dispose(bool)': no suitable method found to override  C:\Users\logicwaves\Documents\Visual Studio 2005\Projects\center\center\Form1.Designer.cs   14  33  center</p>

<p>2)Error 2   Program 'C:\Users\logicwaves\Documents\Visual Studio 2005\Projects\center\center\obj\Debug\center.exe' has more than one entry point defined: 'center.Program.Main()'   C:\Users\logicwaves\Documents\Visual Studio 2005\Projects\center\center\Program.cs  13  21  center</p>

<p>3)Error 3   Program 'C:\Users\logicwaves\Documents\Visual Studio 2005\Projects\center\center\obj\Debug\center.exe' has more than one entry point defined: 'CenterForm.Main()'   C:\Users\logicwaves\Documents\Visual Studio 2005\Projects\center\center\Form1.cs    58  17  center</p>

<p>what should i do, to overcome from these errors?</p>
