Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DrawIcon Method (Icon, Int32, Int32)
Collapse the table of content
Expand the table of content

Graphics.DrawIcon Method (Icon, Int32, Int32)

Draws the image represented by the specified Icon at the specified coordinates.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

member DrawIcon : 
        icon:Icon * 
        x:int * 
        y:int -> unit

Parameters

icon
Type: System.Drawing.Icon

Icon to draw.

x
Type: System.Int32

The x-coordinate of the upper-left corner of the drawn image.

y
Type: System.Int32

The y-coordinate of the upper-left corner of the drawn image.

ExceptionCondition
ArgumentNullException

icon is a null reference (Nothing in Visual Basic).

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates an icon from a standard Windows icon file SampIcon.ico in the example folder.

  • Creates the coordinates of the upper-left corner at which to draw the icon.

  • Draws the icon to the screen.

The drawn icon is unscaled.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft