Jump to content

Custom Icon on Menus


 Share

Recommended Posts

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.

image.png.b0f5c0541943e1d24dbbb0d9692d60bb.png

Link to comment
Share on other sites

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;
                    }
                }
            }

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...