Click here to Skip to main content
14,239,876 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want to use icon from application resources folder i don't want to use in this way

<system.drawing.toolboxbitmap("c:\usercontrolicon\bin\debug\icon.ico")>

Use in this way
<system.drawing.toolboxbitmap(global.usercontrolicon.my.resources.icon)>

What I have tried:

<system.drawing.toolboxbitmap("c:\usercontrolicon\bin\debug\icon.ico")>
<system.drawing.toolboxbitmap(global.usercontrolicon.my.resources.icon)>
Partial Public Class ControlIcon
Inherits Windows.Forms.TextBox


End Class
End Namespace
Posted
Updated 10-Jul-19 5:38am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

ToolboxBitmapAttribute(Type, String)[^]
With this overload of the constructor, you will be able to specify the icon as an embedded resource in the assembly.

First, in the Solution Explorer, select the icon.ico file, and in the Properties window, set the build action for the icon to EmbeddedResource.

Then, declare the attribute this way:
<System.Drawing.ToolboxBitmap(GetType(ControlIcon), "icon.ico")> _
Partial Public Class ControlIcon
Inherits Windows.Forms.TextBox
   
Comments
Computechsoft 10-Jul-19 15:38pm
   
Thanks phil.o Its help full very easy to control icon

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100