I created this within a drawing method
private void draws()
{
Bitmap bmp = new Bitmap(pictureBox17.Width, pictureBox17.Height);
using (Graphics g = Graphic
Try creating the Bitmap outside of the function to preserve it, the way you are doing it now disposes of the Bitmap element after the function has completed.
you could then do something like
Bitmap bmp = new Bitmap(pictureBox17.Width, pictureBox17.Height);
private void draws()
{
if (bmp ==null)
using (Graphics g = Graphics.FromImage(bmp))
{
//define area do pictureBox17 e preenche a branco
Brush brush = new SolidBrush(Color.White);
Rectangle area = new Rectangle(0, 0, pictureBox17.Width, pictureBox17.Height);
g.FillRectangle(brush, area);
//desenha as linhas do rectangulo
g.DrawLine(new Pen(Color.Black), esp, esp, esp, yWcorrigidoesp);
}
else {
using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawLine(new Pen(Color.Black), esp, esp, esp, yWcorrigidoesp);
}
// some more lines
}
pictureBox17.Image = bmp;
}
Just to get you started.. :)
Alternatively you can pass the bmp into the draw function if you use this method to draw multiple bmp at different times