title: Saving a Graphics content to a file
body: <p>I have some code where I draw a function graph into a <code>PictureBox</code> graphics. The code is implemented in the <code>Paint</code> event. At some point I want to save a bitmap of the content of the graphics in a file. </p>
  
  <p>I already read the answers to <a href="https://stackoverflow.com/questions/4305168/saving-graphics-to-bitmap-outside-of-paint">this question</a>, and didn't found what I was looking for. </p>
  
  <p>What I need is both to draw in the PictureBox (or any other control that you suggest) so that I don't loose the drawing when the control is hidden or something (so I think I cannot <code>CreateGraphics()</code>) <em>and</em> be able to save that drawing in a button's click event.</p>
  
  <p>I'm willing to put the drawing logic out of the <code>Paint</code> event if necesary.</p>
  
  <p>Thanks in advance.</p>