Amy Piddington Posted July 4, 2024 Posted July 4, 2024 Would like to add my own custom menu icon to some bespoke reports. When I browse and select the dll I have created containing my icons, they do not display in the select icon window. The dll does contain valid icon files as I can use it on other apps/shortcuts. Any suggestions appreciated.
Chris Burke Posted July 5, 2024 Posted July 5, 2024 You don't need to do anything particularly unusual to make your icons available - I just have mine as embedded resources in the assembly. One thing you *do* need to do is make sure you have two copies of each icon suffixed with '_LIGHT' and '_DARK' - so something like 'MyQuotes_LIGHT.ico' and 'MyQuotes_DARK.ico' for example. However, that only gets validated once you've selected the icon - it won't prevent them from appearing in the list for selection in the first place. For what it's worth, this is what's happening behind the 'Select Icon' form when you browse to your assembly. Maybe you could try running this and see if you can spot where it's failing: Assembly assembly = Assembly.LoadFile([PATH TO MY DLL]); var assemblyImageList = new ImageList(); assemblyImageList.ImageSize = new Size(16, 16); assemblyImageList.ColorDepth = ColorDepth.Depth32Bit; foreach (string mrn in assembly.GetManifestResourceNames()) { using (Stream resStream = assembly.GetManifestResourceStream(mrn)) { try { Icon icon = new Icon(resStream); assemblyImageList.Images.Add(mrn, icon); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); resStream.Position = 0L; } } } 1
Amy Piddington Posted July 17, 2024 Author Posted July 17, 2024 Thank You Chris - that worked a treat - I just kept altering my dll until and running that code until it work. Thank You! 1
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now