I have a form with two panels. I am trying to save the contents of Panel2 as an image. I saw a thread that talked about using screen capture to do this, but I can no longer find the stream. Also read about using the DrawToBitMap method, but it is from visual studio 2005 information, not sure if this is the most relevant or suitable solution for this. So what do you recommend to save my Panel2 as an image, preferably jpg?
UPDATE: I applied the code below for DrawToBitMap, but it saves half of my panel2 (left half if that matters). Since it saved half of my panel2, I multiplied the width call by "2" to keep the full shape. Something strange and does not make sense to me, since the width of panel 2 should be a full panel, not half?
//multiplies the width of panel2 call by 2 to make it save the full panel Bitmap bmp = new Bitmap(splitContainer1.Panel2.Width * 2, splitContainer1.Panel2.Height); splitContainer1.Panel2.DrawToBitmap(bmp, splitContainer1.Panel2.Bounds); bmp.Save(@"C:\Test.bmp");
source share