drawing takes a few seconds?

J

Jeroen Ceuppens

When I draw a bmp, it takes e few seconds before it shows on the screen, is
it because the onpain method is only active after x seconds? What can I
change about the code to let the bmp drawn immediatly?

CODE:
private void button1_Click(object sender, System.EventArgs e)

{

draw=true;

bmp = new Bitmap(@"\\GERONIMO\im\ImageWarpIllum.bmp");

this.Invalidate(new Rectangle(100,100,100,100));

//this.Refresh();

}

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint(e);


g=this.CreateGraphics();

if (draw)

g.DrawImage(bmp,100,100);

}
 
M

Maarten Struys eMVP

Have you tried using this.Update()?

Regards,
Maarten Struys, eMVP
PTS Software bv
 
A

Alex Yakhnin [MVP]

Don't create Graphics in the OnPaint event. Use the one
that's passed in the event itself:


protected override void OnPaint(PaintEventArgs e)
{
if (draw)
e.Graphics.DrawImage(bmp,100,100);

base.OnPaint(e);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top