Drawing to the Screen

No matter what kind of drawing you're doing, the underlying abstraction that you're dealing with is the Graphics class from the System.Drawing namespace. The Graphics class provides the abstract surface on which you're drawing, whether the results of your drawing operations are displayed on the screen, stored in a file, or spooled to the printer. The Graphics class is too large to show here, but we'll come back to it again and again throughout the chapter.

One way to obtain a Graphics object is to use CreateGraphics to create a new one associated with a form:

 Dim drawEllipse As Boolean = False Sub drawEllipseButton_Click(sender As Object, e As EventArgs) _ Handles drawEllipseButton.Click ' Toggle whether or not to draw ...

Get Windows Forms Programming in Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.