Set - 5

Question 41 :

How do you trigger the Paint event in System.Drawing?

Answer :

Invalidate the current form, the OS will take care of repainting. The Update method forces the repaint.


Question 42 :

With these events, why wouldn't Microsoft combine Invalidate and Paint, so that you wouldn't have to tell it to repaint, and then to force it to repaint?

Answer :

Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it allows for the process to take place in the background.


Question 43 :

How can you assign an RGB color to a System.Drawing.Color object?

Answer :

Call the static method FromArgb of this class and pass it the RGB values.


Question 44 :

What class does Icon derive from? Isn't it just a Bitmap with a wrapper name around it?

Answer :

No, Icon lives in System.Drawing namespace. It's not a Bitmap by default, and is treated separately by .NET. However, you can use ToBitmap method to get a valid Bitmap object from a valid Icon object.


Question 45 :

Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET dynamically?

Answer :

By using System.Drawing.SystemIcons class, for example System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.