I mostly use Console or Forms applications in VS for my projects.
Did anyone among you ever use an Empty Project when starting a new one?
Well, it is as clean as you can get with Visual Studio! The world is at your feet!
I use it mainly to test some drawing methods from the Graphics class.
To get a feeling of it, let’s start a new empty project.
I called mine “Draw” and I right clicked it to get the properties window and set the Output type: to Windows Application, to avoid that a console window opens also.
Because it is an empty project, you are responsible for the References you want to use.
Here I used
Now in the Program.cs file fill in these 40 lines or so, remember this in fact a complete project! Enjoy!

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

namespace Draw
    public class DrawingForm : Form
        public DrawingForm() // contructor
            this.Text = "My drawings"; // title of window form
            this.Size = new Size(600, 600); // size of window form
            this.Paint += new PaintEventHandler(MyPainting); // install handler

        private void MyPainting(object sender, PaintEventArgs e)
            Graphics G = e.Graphics;

            // Test some GDI+ drawing here: methods to draw from point to point
            Pen redPen = new Pen(Color.Red,2);
            Pen bluePen = new Pen(Color.Blue,4);
            Pen blackPen = new Pen(Color.Black,6);
            Point[] pnts = { new Point(50,  150), new Point(200, 350),
                             new Point(400, 200), new Point(350, 150),
                             new Point(450, 100), new Point(550, 400),
                           new Point(400, 300)};
            G.DrawLines(redPen, pnts); // draw from point to point
            G.DrawCurve(bluePen, pnts); // draw splines
            G.DrawBeziers(blackPen, pnts); //needs 7 points

    public class Program //main program
        public static int Main()
            Application.Run(new DrawingForm()); // run a form
            return 0; // let the OS know everything is OK
5 Years
Discussion Span
Last Post by ddanbe


Main() method should have STAThread attribute. Every windows application should always declare the Apartment Thread attribute.

Edited by happygeek: fixed formatting


Although I worked for some time, without any problem with this little thing, your statement is correct. Thanks for pointing that out :)

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.