The PaintBox control should be 200 pixels high. Use a memory bitmap to do off screen drawing. Now find the pixel that represents the water level. Your water level meter should be more robust. Fill in the water portion of the tank with blue. rect .
Many programmers like to place all of their painting code in one location.
In the previous example, the painting code resides in an OnPaint handler. Unfortunately, the PaintBox flickers whenever the water level changes because the Repaint call results in a call to the API InvalidateRect function. You could replace Repaint with Refresh or with a combination of Invalidate and Update , but the flicker would persist. This is not true. Refresh simply calls Repaint , so the two are the same.