0

I have a panel on which I have drew several shapes, text and added picture boxes dynamically. I want to take a screenshot of the panel so I can save it. I tried the code below but it only gives me the panel's background image and the child controls, the drawings are missing. Help!

Bitmap bit = new Bitmap(pnlKanvas.Width, pnlKanvas.Height);
pnlKanvas.DrawToBitmap(bit, new Rectangle(0, 0, bit.Width, bit.Height));
Ouranos
  • 39
  • 8

1 Answers1

0

Use CreateGraphics call to draw on an Image/Bitmap. Use that bitmap as your panel's background image, then do what you are trying...

Adding code..

Dim img As Image = New Bitmap(1500, 1500)
Dim g As Graphics = Graphics.FromImage(img)

'Do what ever you have done using ... abc.CreateGraphics.Something() as g.Something()
'see below

g.Clear(Color.White)
g.DrawImage(fpicGear(piIndex + 1).picGear, lTempXpos, lTempYpos)
g.DrawString(tString, New Font("Arial", 8, FontStyle.Regular), brushColor, New Point(lXTextPosition, lYTextPosition))
myPanel.BackgroundImage = img
Sarvesh Mishra
  • 2,014
  • 15
  • 30