Draw an object and update it's position on a panel without flickering
<p>I want to avoid the flickering, and I also don't want to use a timer. Is there a method for when the form updates or when the graphics get refreshed that I can use instead of a timer?</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace test
{
    public partial class Form1 : Form
    {
        SolidBrush sb = new SolidBrush(Color.White);
        Pen p = new Pen(Color.LightGray, 3);
        Graphics g;  
        int xpos;
        int ypos;

        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            g = panel1.CreateGraphics();
            this.DoubleBuffered = true;  
        }    
        void Draw(string Shape, int x, int y)
        {
            panel1.Invalidate();
            switch (Shape)
            {
                case "Circle":
                    g.FillEllipse(sb, x, y, 20, 20);
                    g.DrawEllipse(p, x, y, 20, 20);
                    break;
            }  
        }
        private void tmrAnimaion_Tick(object sender, EventArgs e)
        {

            xpos += 2;
            Draw("Circle", xpos, ypos);
            if (xpos &gt;= 700)
            {
                xpos = 0;
                ypos += 20;
            }
        }
    }
}
</code></pre>
