我不断得到一个InitializeComponent();我的代码中有错误

时间:2019-12-01 21:08:55

标签: c# initializecomponent

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

namespace Form1
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.Paint += Form1_Paint;
        this.Invalidate(); /// this fires Paint event
        this.BackColor = System.Drawing.Color.Black;
    }
    Pen red = new Pen(Color.Red);
    Pen green = new Pen(Color.Green);

    System.Drawing.SolidBrush fillRed = new System.Drawing.SolidBrush(Color.Red);
    System.Drawing.SolidBrush fillYellow = new System.Drawing.SolidBrush(Color.Yellow);

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawRectangle(red, 100, 0, 220, 90); //(xpos., ypos., sizex, sizey)
        e.Graphics.DrawEllipse(green, 100, 0, 220, 90); //(xpos., ypos., sizex, sizey)
    }

    BallClass.Ball b = new BallClass.Ball(140, 510, 30, 30, 1, 1);
    BallClass.Ball b2 = new BallClass.Ball(140, 500, 10, 10, 1, 1);
    PaddleClass.Paddle p = new Paddle(140, 510, 30, 30);
    BrickClass.Brick br = new BrickClass.Brick(20, 20, 30, 30);

} 
}

我已经尝试了所有已知的知识,但无法通过此错误。每当我运行此代码时, 我遇到以下错误:名称'InitializeComponent'在当前上下文中不存在。拜托,有人可以告诉我发生了什么事吗?

0 个答案:

没有答案