my DrawImage doesn't draw when addes to the c-tor

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

This code works fine when added to event handler for the forms paint event.
If I instead add the three rows to the Forms c-tor
nothing is being drawn in the form why?
private void Form1_Paint(object sender, PaintEventArgs e)
{
Bitmap bm = new Bitmap("background3.bmp");
Graphics g = this.CreateGraphics();
g.DrawImage(bm, 1, 1, this.Width, this.Height);
}

I can for example add these two rows to the forms c-tor and it works fine.
Image i = Image.FromFile("background3.bmp");
this.BackgroundImage = i;

//Tony
 
Back
Top