C# Take ScreenShot of .net control within application and attach to Outlook Email
.net, c#, controls, screenshot, winforms
Solution
If you just want to the `Panel's` screenshot, you can use the built-in DrawToBitmap method.
Bitmap bmp = new Bitmap(myPanel.Width, myPanel.Height);
myPanel.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save(@"C:\MyPanelImage.bmp");
Just note that some controls may not work with this functionality such as the `WebBrowser` and `RichTextBox` controls but it should work for most other controls (textbox, labels etc..)
Problem
Does anyone know how to take a screenshot using C# and limit it to take a picture of a specific container/portion of an application. I do not want the whole screen or whole window of the application. My Panel is simply called: panel1 User would click a "button" and take screenshot of panel1 and attach to email. I would like to take a screen shot of that section only and then save locally to the C:\ Drive and/or attach or embed into an outlook email. I read other various things on the internet but most of them had to deal with creating complex changes in take a screenshot of a web browser control which I am not looking for.