Display the predefined system icons in C#

// Draw samples.Download example
private void Form1_Paint(object sender, PaintEventArgs e)
{
int y = 10;
DrawIconSample(e.Graphics, ref y, SystemIcons.Application, "Application");
DrawIconSample(e.Graphics, ref y, SystemIcons.Asterisk, "Asterisk");
DrawIconSample(e.Graphics, ref y, SystemIcons.Error, "Error");
DrawIconSample(e.Graphics, ref y, SystemIcons.Exclamation, "Exclamation");
DrawIconSample(e.Graphics, ref y, SystemIcons.Hand, "Hand");
DrawIconSample(e.Graphics, ref y, SystemIcons.Information, "Information");
DrawIconSample(e.Graphics, ref y, SystemIcons.Question, "Question");
DrawIconSample(e.Graphics, ref y, SystemIcons.Warning, "Warning");
DrawIconSample(e.Graphics, ref y, SystemIcons.WinLogo, "WinLogo");
this.ClientSize = new Size(this.ClientSize.Width, y);
}
// Draw a sample and its name.
private void DrawIconSample(Graphics gr, ref int y, Icon ico, string ico_name)
{
gr.DrawIconUnstretched(ico, new Rectangle(10, y, ico.Width, ico.Height));
int text_y = y + (int)(ico.Height - gr.MeasureString(ico_name, this.Font).Height) / 2;
gr.DrawString(ico_name, this.Font, Brushes.Black, ico.Width + 20, text_y);
y += ico.Height + 5;
}
-->
Comments