Tip
It is recommended to use multi-resolution icons in a DPI aware application. You can use the predefined icons
from the Icons class.
[DefaultValueAttribute(IconSizeMode.AutoScale)]
public IconSizeMode IconSizeMode { get; set; }<DefaultValueAttribute(IconSizeMode.AutoScale)>
Public Property IconSizeMode As IconSizeMode
Get
Setpublic:
[DefaultValueAttribute(IconSizeMode::AutoScale)]
property IconSizeMode IconSizeMode {
IconSizeMode get ();
void set (IconSizeMode value);
}[<DefaultValueAttribute(IconSizeMode.AutoScale)>]
member IconSizeMode : IconSizeMode with get, setIf the value of this property is SystemDefault, the behavior is framework dependent. Older frameworks may simply pick the smallest image from the assigned icon, which still may be too large if the icon contains only a large image. Starting with .NET 8.0 the ErrorProvider provider class supports multi-resolution icons, though only the existing resolutions are used, similarly to the GetNearestSize mode.
If the property is set to AutoScale or GetNearestSize, the reference size on 100% DPI is 16 x 16 pixels.
To make auto-scaling work for per-monitor DPI awareness, the ContainerControl property must not be . The Windows Forms designer sets the ContainerControl automatically if you add the AdvancedErrorProvider to the form or user control from the Toolbox.
To autoscale the default icon as well, just get and set it explicitly: myErrorProvider.Icon = myErrorProvider.Icon;