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


Tony Johansson


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;


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