Page 1 of 1

tChart is not drawn when I draw the whole Form to bitmap

Posted: Wed Oct 12, 2011 1:29 pm
by 15659327
I want to draw a whole System.Windows.Form to Bitmap (make a screenshot of the form). Everything works fine, and all controls are drawn to the bitmap. The only exception is that the tChart contained in the Form does not appear in the bitmap. I ise the following code:

private void button1_Click(object sender, EventArgs e)
{
Bitmap m_oScreenshot = new Bitmap(Width, Height);
Rectangle r = new Rectangle(0, 0, Width, Height);
this.DrawToBitmap(m_oScreenshot, r);
m_oScreenshot.Save("D:\\temp\\Test.bmp");
}

this means the form itself.

What can I do that the Chart is drawn to the bitmap? Thanks in advance.

Re: tChart is not drawn when I draw the whole Form to bitmap

Posted: Thu Oct 13, 2011 1:14 pm
by 10050769
Hello koni,


I suggest do something as next code:

Code: Select all

  private void button1_Click(object sender, EventArgs e)
        {
            Bitmap m_oScreenshot = new Bitmap(Width, Height);
            Graphics gfx = Graphics.FromImage((Image)m_oScreenshot);
            gfx.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(Width, Height));
            m_oScreenshot.Save("C:\\temp\\test.bmp", ImageFormat.Bmp);   
        }
Can you tell us if previous code works as you expected?

I hope will helps.

Thanks,

Re: tChart is not drawn when I draw the whole Form to bitmap

Posted: Fri Oct 14, 2011 8:50 am
by 15659327
It works.
Thank you very much!