C# Drawing a Bitmap on a certain point in a PictureBox
<p>I currently have a <code>Bitmap</code> image. I need to place this image at a certain coordinate inside a <code>PictureBox</code>. Specifically, I'm looking to place it 5 pixels from the top and 5 pixels from the left. The bitmap will be of different lengths, so I want the starting point to always start drawing the <code>Bitmap</code> at this specific point.</p>

<p>As an example, here are two "Bitmaps" that both start at the coordinate 5,5, with different lengths. Imagine the Gray is the <code>PictureBox</code>:</p>

<p><a href="https://i.stack.imgur.com/uaVh5.png" rel="nofollow"><img src="https://i.stack.imgur.com/uaVh5.png" alt=""></a> <a href="https://i.stack.imgur.com/Ghl5o.png" rel="nofollow"><img src="https://i.stack.imgur.com/Ghl5o.png" alt=""></a>
<br>
I've tried something like passing in a <code>PictureBox</code> and using graphics to draw the bitmap:</p>

<pre><code>private void setQuantity(PictureBox pb, int quantity) {

    Graphics g = pb.CreateGraphics();

    g.DrawImage(iqc.createQuantityImage(quantity), 0, 0);

    g.Dispose();

}
</code></pre>

<p><code>iqc.createQuantityImage() returns a Bitmap</code>
<br></p>

<p>But this doesn't seem to draw anything. I have also changed the x and y and nothing changes.</p>

<p>I'd like to be able to specify the exact coordinate or point inside the <code>PictureBox</code> if possible.</p>

<p>Thanks for any help!</p>