I'd like to use the standard error icon (Standard Icons) on a Windows Forms dialog. How can the error icon be loaded into an Image for display?
I have to sputter at the horrid waste of burning up such expensive resources as a Control and a Windows window, just to draw a dinky icon. To save one line of code:
protected override void OnPaint(PaintEventArgs e) {
e.Graphics.DrawIcon(SystemIcons.Error, 10, 10);
base.OnPaint(e);
}
If you're using Visual Studio's Designer, add a PictureBox object. Then in code, set your PictureBox's Image property:
dialog.PictureBox.Image = SystemIcons.Error.ToBitmap();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With