SystemIcons.GetStockIcon Method

Definition

Overloads

GetStockIcon(StockIconId, StockIconOptions)

Gets the specified Windows shell stock icon.

GetStockIcon(StockIconId, Int32)

Gets the specified Windows shell stock icon.

GetStockIcon(StockIconId, StockIconOptions)

Source:
SystemIcons.cs
Source:
SystemIcons.cs
Source:
SystemIcons.cs
Source:
SystemIcons.cs

Gets the specified Windows shell stock icon.

C#
public static System.Drawing.Icon GetStockIcon(System.Drawing.StockIconId stockIcon, System.Drawing.StockIconOptions options = System.Drawing.StockIconOptions.Default);

Parameters

stockIcon
StockIconId

The stock icon to retrieve.

options
StockIconOptions

A bitwise combination of the enumeration values that specifies options for retrieving the icon.

Returns

The requested Icon.

Exceptions

stockIcon is an invalid StockIconId.

Remarks

Unlike the static icon properties in SystemIcons, this API returns icons that are themed for the running version of Windows. Additionally, the returned Icon is not cached and should be disposed when no longer needed.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
Windows Desktop 8, 9

GetStockIcon(StockIconId, Int32)

Source:
SystemIcons.cs
Source:
SystemIcons.cs
Source:
SystemIcons.cs
Source:
SystemIcons.cs

Gets the specified Windows shell stock icon.

C#
public static System.Drawing.Icon GetStockIcon(System.Drawing.StockIconId stockIcon, int size);

Parameters

stockIcon
StockIconId

The stock icon to retrieve.

size
Int32

The desired size. If the specified size does not exist, an existing size will be resampled to give the requested size.

Returns

The requested Icon.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
Windows Desktop 8, 9