Form invalidate() in WinForms Application

Posted by Pramodh on Stack Overflow See other posts from Stack Overflow or by Pramodh
Published on 2010-05-14T12:19:39Z Indexed on 2010/05/14 12:54 UTC
Read the original article Hit count: 369

Filed under:
|

i need to animate an object in c# windows application

int l_nCircleXpos = 9, l_nCircleYpos = 0;

private void Form1_Paint(object sender, PaintEventArgs e)
{
    Graphics l_objGraphics = this.CreateGraphics();
    Pen l_circlePen = new Pen(Color.Blue);
    SolidBrush l_circleBrush = new SolidBrush(Color.Blue);
    l_objGraphics.DrawEllipse(l_circlePen, l_nCircleXpos, l_nCircleYpos, 30, 30);
    l_objGraphics.FillEllipse(l_circleBrush, l_nCircleXpos, l_nCircleYpos, 30, 30);
    Pen l_rectPen = new Pen(Color.Red);
}

private void timer1_Tick(object sender, EventArgs e)
{
    l_nCircleXpos++;
    l_nCircleYpos++;
}

private void timer2_Tick(object sender, EventArgs e)
{
    Invalidate();
}

but in timer2 its invalidating the entire form. i need to invalidate the specific circle area only.

please help to do this in a better way

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms