ramezani.saleh
ramezani.saleh

Reputation: 571

Use System Images in C#

I am creating a custom messagebox. How can I use system pictures such as Error, Information, Warning and etc, which I see in windows MessageBox? I want to access them directly!

Upvotes: 8

Views: 8968

Answers (3)

Kristoffer Lindvall
Kristoffer Lindvall

Reputation: 2682

Take a look at System.Drawing.SystemIcons. You should find them there.

Then set your PictureBox (assuming Winforms here) like this:

PictureBox1.Image = System.Drawing.SystemIcons.Warning.ToBitmap();

Upvotes: 23

to StackOverflow
to StackOverflow

Reputation: 124696

You can draw the System icons in your custom MessageBox by handling the Paint event, e.g.

void MyMessageBox_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.DrawIcon(SystemIcons.Warning, 16, 16);
}

Upvotes: 0

Dave
Dave

Reputation: 1076

You need to look into the messagebox class a little further. You can specify a "MessageBoxIcon" when calling the method.

There are some good examples on how to acheive this here: http://www.dotnetperls.com/messagebox-show

Upvotes: 0

Related Questions