Attaching an ICON with the RequiredTextBox Control
In this article we are going to demonstrate how to attach an image icon with your custom server control. We highly recommend that you check out the previous articles and videos about building RequiredTextBox control.
Creating an ICON for your server control will give it a distinct look in the Toolbox. Control developers try to create the best ICON for their control as they know that a better looking ICON is very important for a control user.
The first thing you need to do is to add an ico file in your project. Right click on your control project and add a new "ico" file. Open the file and select 16X16 dimension. You can use the Visual Studio icon editor to create your icon. The VS editor is very limited so you can always take a look at third party tools or hire someone to create an icon for your control.
Here is the icon we created for our RequiredTextBox control:
The next step is to attach the icon with the RequiredTextBox control. First you must set up the build action of the icon file as "Embedded Resource". Next, attach the attribute to your class as shown below:
Be sure to name the icon same as the name of the control.
And that is pretty much it! Now, when you add the control to your Toolbox it will appear with an icon as shown below: