1. Design Icon Fig. 1 Fig. 2 Both Figure 1 and Figure 2 are icons, but the background color of Figure 1 is transparent, while Figure 2 shows opaque background color. Sometimes you may choose the background color of the pane where the icon shows on, but what if the pane is not monochromic?
Let me show you how to design an icon with transparent background color.
When you design icon with Microsoft Visual Studio 2003/2005, use the Eraser Tool to wipe off the background when you design an icon. Even when you need to modify part of your design, you must still use the eraser to wipe it off first. Although the Eraser color looks like the green color in the color pallet, it is different. You can use the icon with transparent background as an application icon, system tray icon, or desktop icon, and the icon shows without its own background color, just like what Figure 1 demonstrates. 2. Show Picture with Transparent Background Color 
Fig. 3 Fig. 4 Both Figure 3 and Figure 4 are pictures shown on a Windows form. Figure 3 shows clear background, while figure 4 has its own background color. When you assign an image to a picture control on a form, the default image types are gif, ipg, ipeg, bmp, wmf and png, but each of those types would show its own background color.
Let me show you how to do it correctly. Select the picture control on your project form, click the image property and click browse button, which opens the "Select Resource" dialog as shown in Figure 5. Select "Project resource file" option, then click Import button, which opens the file "Open" dialog as shown in Figure 6. Change "Files of type" to All Files (*.*), then select the icon with clear background color, the icon will be loaded to the image category of the project resources.

Fig. 5 
Fig. 6 Then, you can load the image to the picture in your project as the code below.
picture1.Image = YourApp.Properties.Resources.image1; picture1.Image = YourApp.Properties.Resources.image2;
However, if you add icons through the resource editor, the icons are added to the icon category. If you use the above code to assign an icon to a picture, you’ll get a compiler error:
“Cannot implicitly convert type ‘System.Drawing.Icon’ to ‘System.Drawing.Image’”.
To avoid this error, do it correctly as I have shown above. |