Export (0) Print
Expand All

Icon Class

Represents a Windows icon, which is a small bitmap image used to represent an object. Icons can be thought of as transparent bitmaps, although their size is determined by the system.

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

'Declaration
<SerializableAttribute> _
<TypeConverterAttribute(GetType(IconConverter))> _
Public NotInheritable Class Icon
	Inherits MarshalByRefObject
	Implements ISerializable, ICloneable, IDisposable
'Usage
Dim instance As Icon

/** @attribute SerializableAttribute() */ 
/** @attribute TypeConverterAttribute(System.Drawing.IconConverter) */ 
public final class Icon extends MarshalByRefObject implements ISerializable, ICloneable, 
	IDisposable
SerializableAttribute 
TypeConverterAttribute(System.Drawing.IconConverter) 
public final class Icon extends MarshalByRefObject implements ISerializable, ICloneable, 
	IDisposable
Not applicable.

The following code example demonstrates how to use the ToBitmap method. This example is designed to be used with Windows Forms. Create a form and paste the following code into it. Call the IconToBitmap method in the form's Paint event handler, passing e as PaintEventArgs.

Private Sub IconToBitmap(ByVal e As PaintEventArgs)

    ' Construct an Icon.
    Dim icon1 As New Icon(SystemIcons.Exclamation, 40, 40)

    ' Call ToBitmap to convert it.
    Dim bmp As Bitmap = icon1.ToBitmap()

    ' Draw the bitmap.
    e.Graphics.DrawImage(bmp, New Point(30, 30))
End Sub

private void IconToBitmap(PaintEventArgs e)
{
    // Construct an Icon.
    Icon icon1 = new Icon(SystemIcons.get_Exclamation(), 40, 40);

    // Call ToBitmap to convert it.
    Bitmap bmp = icon1.ToBitmap();

    // Draw the bitmap.
    e.get_Graphics().DrawImage(bmp, new Point(30, 30));
} //IconToBitmap

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft