```
namespace MiniPaint
{
    public partial class Form1 : Form
    {
        Graphics g;
        Pen p = new Pen(Color.Black, 1);
        Point sp = new Point(0, 0);
        Point ep = new Point(0, 0);
        int k = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void red_Click(object sender, EventArgs e)
        {
            p.Color = red.BackColor;
            default1.BackColor = red.BackColor;
        }

        private void green_Click(object sender, EventArgs e)
        {
            p.Color = green.BackColor;
            default1.BackColor = green.BackColor;
        }

        private void blue_Click(object sender, EventArgs e)
        {
            p.Color = blue.BackColor;
            default1.BackColor = blue.BackColor;
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            sp = e.Location;
            if (e.Button == MouseButtons.Left) ;
            k = 1;

        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            k = 0;

        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (k == 1)
            {
                ep = e.Location;
                g = this.CreateGraphics();
                g = DrawLine(p, sp, ep);
            }

            sp = ep;

        }
    }
}

```

Hello guys! Im having a problem with this code and the title is my error. Im pretty new with c# and graphics too, I understand this code,(partially wrote it myself but this error is driving me crazy). Can anyone tell me where im mistaken and explain it to me? Thanks in advance! And btw is there an easy way for example via button to delete everything thats going to be painted on the form and how can i do that?