Loads icon images from a stream containing an icon file into the Image and LargeImage properties.
Icon files can contain more than one image, although the Icon class does not provide an easy method to choose which image is used. Use this method to specify the single image to load from an icon.
This method supports loading 32-bit icons that contain an 8-bit alpha channel, even on older operating systems that do not normally support these icons, such as Windows 98, ME, and 2000.
If the specified size or color depth does not exist in the icon, the existing Image and LargeImage property values are not changed.
You can learn more about how to use this method from the 7. Extended Support for Windows Icons topic in the Programmer's Guide
This example loads the images for 2 buttons. The first image is loaded from an icon file called "button.ico", and the second is loaded from an embedded resource in the assembly. These examples also require System.IO and System.Reflection to be imported into the file that contains them.
// Load a 16x16 image from an icon file called "button.ico". The image is loaded into the .Image // property of rebarButton1. using (Stream fileStream = new FileStream("button.ico", FileMode.Open)) rebarButton1.LoadIconImage(fileStream, new Size(16, 16)); // Load two images from a single icon embedded resource. "TestProject" specifies the namespace that contains // the resource and "search.ico" specifies the filename of the embedded resource. // The first image is 16x16 and is loaded into the .Image property. The second image is 24x24 and is // loaded in the .LargeImage property. Both images have an 8-bit color depth. Assembly assembly = Assembly.GetExecutingAssembly(); using (Stream resourceStream = assembly.GetManifestResourceStream("TestProject.search.ico")) rebarButton2.LoadIconImage(resourceStream, new Size(16, 16), new Size(24, 24), ColorDepth.Depth8Bit);
RebarButton Class | Skybound.Rebar Namespace | RebarButton.LoadIconImage Overload List