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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.