There is a class CRenderer , an instance of which, after creation, binds to itself a certain Control and performs some actions on drawing a BackgroundImage :
class CRenderer { private Bitmap m_bitMap; private Graphics g; private Control m_cntrl; public CRenderer() {} public void Bind(Control cntrl) { m_cntrl = cntrl; m_bitMap = new Bitmap(m_cntrl.Width - 1, m_cntrl.Height - 1); g = Graphics.FromImage(m_bitMap); m_cntrl.BackgroundImage = m_bitMap; g.Clear(Color.White); DrawXYGrid(); } private void DrawBox() { /*Работаем только с g*/ } private void DrawXYGrid() { /*Работаем только с g*/ } public void Draw2DPoints(Model._2DPoint[] points) { /*Работаем только с g*/ } } Thus, the same type of actions are performed on different Controls, in this case they are two PictureBoxes.
renderer = new View.CRenderer(); renderer.Bind(pictureBox1); ren2grph = new View.CRenderer(); renderer.Bind(pictureBox2); Then, it works out a function that only works with render (respectively, with pictureBox1). But the snag is that the drawing goes - in pictureBox2. What could be the error? Maybe you can not encapsulate BitMap in a separate class? Or spawn multiple Graphics objects?