Search code examples
winformssystem.drawing

Painting change on Graphics not shown unless minimizing window


I created painting app, where i can paint on Panel, however, the change (what i paint) is shown only when i minimize window (form) and then open it again. I want to see what i paint immediately.

Steps to reproduce:

Panel panel = new Panel();
//adding panel to view
Bitmap bitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(bitmap);
panel.BackgroundImage = bitmap;
//painting something on g

Solution

  • Solution was to use PictureBox instead of Panel, Painting on it became visible and more smooth.