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);
}
--
Alex Yakhnin, .NET CF MVP
http://www.intelliprog.com
http://www.opennetcf.org
>-----Original Message-----
>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);
>
>}
>
>
>.
>