Search code examples
c#visual-studiocontrolsweb-controlstoolbox

Including embedded image as Toolboxbitmap


Common practice to show a image of control in visual studio toolbox includes embedding the image as a Resource. Instead i tried embedding the image file (sidebar.png) into a resource file Resources.resx. I don't have the lightest clue as to how i can set the image as toolboxbitmap. I tried below & no image appears, could you give me right thing to do here

[ToolboxBitmap(typeof(Sidebar),"sidebar")]
public class Sidebar : WebControl

where "sidebar" string represents the name of the image in the resx file that needs to be shown as a icon in visual studio toolbox.

note: All other posts details on how to include when the image is a embedded resource, not when inside a resource file.


Solution

  • Visual Studio toolbox images must be linked to your assembly as embedded resources, placing them in a resx/resources file is not currently supported.

    Source: GetBitmapFromResource() method of the System.Drawing.ToolboxBitmapAttribute type (as of .NET 4.0).