Graphics Class Drawing Methods

To begin using any of the graphics functions in the .NET Compact Framework, you must first obtain an instance of the Graphics class. You can then use its methods to render shapes, lines, text, and bitmaps to its surface. You obtain a Graphics object reference in one of the following ways:

  • Use the CreateGraphics method of the form or custom control to obtain a reference to the Graphics object that represents the drawing surface of the control or form. This method is used to draw to a form or custom control that already exists, as shown in the following code:

    Graphics MyGraphicsObject = this.CreateGraphics();
  • Use the FromImage method to work with an object that inherits from the Image class (such as a bitmap). Using this ...

Get Microsoft® .NET Compact Framework (Core Reference) 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.