i 在这里是新的,实际上,我正在着手进行正处在正文的项目,而在该项目中,我想要在屏幕中心展示我的形式。 因此,我撰写了以下法典。
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;
}
but it is giving some errors,that are 1)Error 1 center.Form1.Dispose(bool) : no suitable method found to override C:UserslogicwavesDocumentsVisual Studio 2005ProjectscentercenterForm1.Designer.cs 14 33 center
2)不可逆转2方案 C:UserslogicwavesDocumentsVisualroom 2005 ProjectscentercenterobjDebugcenter.exe 有一个以上的切入点:中心。 Program.Main() C:UserslogicwavesDocumentsVisualroom 2005 Projectscentercenter Programram.cs 13 21 Centre
3) 不可逆转方案 C:UserslogicwavesDocumentsVisualroom 2005 ProjectscentercenterobjDebugcenter.exe 有一个以上入境点:Main()中心 C:UserslogicwavesDocumentsVisualroom 2005 ProjectscentercenterForm1.cs 58 17 Center
应当做些什么来克服这些错误?