And it's done. A filled rectangle will be painted at the top of the form.
The code is in the overridden OnPaint() method so that each time the form is resized/obscurred by another form, the content will be re-painted automatically. Also, it is a good practice to call the Dispose methods of objects that consume system resources heavily (e.g. Brush and Graphics objects).