Please see my comment to the question: you omitted some details which makes your situation look uncertain.
I have a general advice for you, based just on the following rule of thumb: if you are starting to have trouble with
PictureBox
, its the time to get rid of it.
This is because this class is not really needed. You can always render any image in any control by yourself, using GDI. The only purpose of the class
PictureBox
is to create a highly simplified way of showing a static image in your application. This is just a middleman between a parent control and the image with scaling, it does not do anything useful if you try to do a bit more.
At the same time, immediate rendering of image on the control is very easy. And it will be dramatically easier in the situations where the
PictureBox
start giving you even the minimal trouble. You can render the image in the cell using a table control (whatever it is,
DataGridView
or anything), or insert any other control, a custom control derived from
System.Windows.Forms.Control
or Panel and render the image on it.
I explain it all and explain what to do in my past answers:
How do I clear a panel from old drawing[
^],
draw a rectangle in C#[
^],
Append a picture within picturebox[
^].
See also these past answers:
Drawing Lines between mdi child forms[
^],
capture the drawing on a panel[
^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^].
Happy New Year!
—SA