0

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
Jacko
  • 29
  • 4
  • 1
    The control does not know that you changed the Bitmap. Add `panel.Invalidate();` – Hans Passant Jan 10 '21 at 18:32
  • @Hans Is that correct way to refresh it? Because now as it redraws everytime i paint something on it fast, it is kind of flickering. – Jacko Jan 10 '21 at 18:38
  • 2
    It is the correct way. Panel is not a great choice, use PictureBox instead to get double-buffering. If you need a panel for scrolling support then [do this](https://stackoverflow.com/a/4306333/17034). – Hans Passant Jan 10 '21 at 18:48

1 Answers1

0

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

Jacko
  • 29
  • 4