title: C# Screenshot of Control is white
body: <p>My question is related to this one: <a href="https://stackoverflow.com/questions/266116/how-to-get-a-screen-capture-of-a-net-control-programmatically">How to get a screen capture of a .Net WinForms control programmatically?</a></p>
  
  <p>I want to take a screenshot of a System.Windows.Forms.Control in C#. I'm using the DrawToBitmap method suggested in the question linked above and that works most of the time. However there are a few problems.</p>
  
  <p><strong>Problem 1</strong>:<br>
  I have two tabpages, let's call them A and B. The Control I want to take a screenshot of is in tabpage B. I want to take the screenshot when a button in tabpage A is pressed. This works most of the time, except when tabpage B hasn't been accessed yet: then the screenshot is just white. If I first access tabpage B, then go back to tabpage A and click the button to take the screenshot then it works fine. I'm guessing this is because of some loading or building of the control in the tab that hasn't been done yet, but I'm not sure what exactly (or it could be something else entirely). I've been trying to force that loading or building using ResumeLayout, PerformLayout, Show, Update, Invalidate but that doesn't work.<br>
  <strong>EDIT:</strong> Managed to solve this by using <code>DrawToBitmap</code> on the containing tabpage control instead of the Control itself and doing a Show on that tabpage.</p>
  
  <p><strong>Problem 2:</strong><br>
  When I take a screenshot of a certain custom Control (a subclass of UserControl) there is a small rectangular white area in the screenshot (where there shouldn't be one obviously). The rectangular area isn't on one particular part of the control like a button or textbox so I'm not sure what's causing this. On other custom Controls (also subclasses of UserControl) it works fine, so that couldn't be the problem itself.<br>
  <strong>EDIT:</strong> Solved it, there was an empty control there that was being drawn on top of it. Setting Visible to false for that control solved it.</p>