How can I display a standard error icon in a Windows C # forms dialog?

I would like to use the standard error icon ( Standard Icons ) in the Windows Forms dialog box. How can an error icon be loaded into an image for display?

+8
c # winforms
source share
2 answers

Using Icon.ToBitmap ()

Bitmap b = SystemIcons.Error.ToBitmap(); 

EDIT:

After three years and another crash, I have to send people who just want to draw an icon to a graphic object to read the answer from @Hans Passant. This is the best solution.

+17
source share

I have to spray on the terrible waste of burning expensive resources like the Control window and the Window, just to draw a damn icon. To save one line of code:

  protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawIcon(SystemIcons.Error, 10, 10); base.OnPaint(e); } 
+7
source share

All Articles