Patrick Marshall
Patrick Marshall

Reputation: 23

I keep getting an InitializeComponent(); error in my code

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);

} 
}

I have tried everything I know and I cannot get passed this error. Everytime I run this code, it gives me the following error: The name 'InitializeComponent' does not exist in the current context. Please, can someone give me an idea of what is going on?

Upvotes: 0

Views: 80

Answers (0)

Related Questions