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”。拜托,有人可以告诉我发生了什么吗?
解决方案
推荐阅读
- javascript - 计算出现次数并创建对象
- javascript - 使用闪亮的网络应用程序生成动态图
- google-app-engine - 使用 OAuth 向 AppEngine HTTP servlet 验证 .NET 客户端
- json - JSON 返回值选择
- ruby - 你如何在 ruby 核心上运行规范?
- floating-point - 使用 MacLaurin 展开的 Fortran Sine 函数的微小差异
- delphi - DBgrid中的Delphi checkox
- python - 为什么我的代码不打印整个列表?
- ruby-on-rails - 呈现 403 验证错误的标准方法
- php - laravel 更新注册用户