Graphics.DrawIcon Method
Draws the image represented by the specified Icon object at the specified coordinates.
Overload List
Draws the image represented by the specified Icon object within the area specified by a Rectangle structure.
[Visual Basic] Overloads Public Sub DrawIcon(Icon, Rectangle)
[C#] public void DrawIcon(Icon, Rectangle);
[C++] public: void DrawIcon(Icon*, Rectangle);
[JScript] public function DrawIcon(Icon, Rectangle);
Draws the image represented by the specified Icon object at the specified coordinates.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Sub DrawIcon(Icon, Integer, Integer)
[C#] public void DrawIcon(Icon, int, int);
[C++] public: void DrawIcon(Icon*, int, int);
[JScript] public function DrawIcon(Icon, int, int);
Example
[Visual Basic, C#] The following 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.
[Visual Basic, C#] The drawn icon is unscaled.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of DrawIcon. For other examples that might be available, see the individual overload topics.
[Visual Basic] Public Sub DrawIconInt(e As PaintEventArgs) ' Create icon. Dim newIcon As New Icon("SampIcon.ico") ' Create coordinates for upper-left corner of icon. Dim x As Integer = 100 Dim y As Integer = 100 ' Draw icon to screen. e.Graphics.DrawIcon(newIcon, x, y) End Sub [C#] public void DrawIconInt(PaintEventArgs e) { // Create icon. Icon newIcon = new Icon("SampIcon.ico"); // Create coordinates for upper-left corner of icon. int x = 100; int y = 100; // Draw icon to screen. e.Graphics.DrawIcon(newIcon, x, y); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
Graphics Class | Graphics Members | System.Drawing Namespace