O'Reilly logo

A Programmer's Guide to .NET by Alexei Fedorov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.7. Practice

Now that we have had an overview of the main functionality provided by the System.Drawing namespace and secondary namespaces, such as System.Drawing. Drawing2D and System.Drawing.Imaging, let’s have some examples that illustrate how to use this functionality.

OnPaint method

To be able to use graphical functions, we need to get a reference to a graphics object – the Graphics class, which provides the device context for drawing. We can do this in the OnPaint event handler, which is called every time the form must be redrawn, such as, when it is created, resized, or moved.

The OnPaint event handler receives a PaintEventArgs object supplied by the system. This object contains various members that specify the Graphics object used ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required