Search code examples
c#winformsscreenshot

Capture screenshot of only a section of a form?


I currently have a winform that, during run time, I need to take a screenshot of a section of it and save it as an image. In particular, I want a screenshot of a panel called "panel1". I've been able to find information on how to get screenshots of entire webforms, or entire screens... but I've had difficulty finding info on getting just a portion of the screen.

Does anyone have any information that could point me in the right direction? Even the name of the documentation on MSDN's site that I should be looking for would be a huge help! Thanks!


Solution

  • The Control class from which Panel derives has a method DrawToBitmap(). You can use that.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx