473,382 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Adding an icon to a user control

!NoItAll
297 100+
Does anyone here have a working example of how to add an icon to a user control - I'm talking about the icon that shows up in the toolbox. I have found some articles on the Microsoft site, but honestly they are so complicated and esoteric that I simply cannot follow them - it's like every synaps in my brain is misfiring when I try to read it!
I would love to see a very simple example of how this should be done.
I've tried embedding the image into the resources, setting the build action to Embedded Resource, creating a ResourceFinder class (as per MS advice) and then preceding the class with:
<ToolboxBitmap(GetType(ResourceFinder), "ExposureMeter.Exposure.bmp")>

.. but so far I feel like I'm shouting into a cave without a single bat flying out...
Jan 11 '12 #1

✓ answered by !NoItAll

Figured it out...

At the top of class, below the namespace place

Expand|Select|Wrap|Line Numbers
  1. Namespace MyNamespace 
  2.     <ToolboxBitmap("MyNamespace.MyClass.bmp")>
  3.     Public Class MyClass
  4.  
Create a bitmap that is 16x16 and name it as above (using the Namespace and class name and go to the Solution Explorer and right-click on the solution (in this case "MyClass" and select Add->Existing Item and add the bitmap file.
The bitmap will now be listed along with all of the resources for the project in the solution explorer. Now right-click on the bitmap in the solution explorer and select Properties. Set the Build Action to "Embedded Resource".

This is what worked for me.

1 4682
!NoItAll
297 100+
Figured it out...

At the top of class, below the namespace place

Expand|Select|Wrap|Line Numbers
  1. Namespace MyNamespace 
  2.     <ToolboxBitmap("MyNamespace.MyClass.bmp")>
  3.     Public Class MyClass
  4.  
Create a bitmap that is 16x16 and name it as above (using the Namespace and class name and go to the Solution Explorer and right-click on the solution (in this case "MyClass" and select Add->Existing Item and add the bitmap file.
The bitmap will now be listed along with all of the resources for the project in the solution explorer. Now right-click on the bitmap in the solution explorer and select Properties. Set the Build Action to "Embedded Resource".

This is what worked for me.
Jan 21 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Meena | last post by:
Hi, I created an user control and tried to add the user control to a test project (windows application). It gave this err message : 'The path is not of a legal form'. I tried adding it at runtime...
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
0
by: Amil | last post by:
I have a reusable web application (e.g. portal). I often do a project copy to create new virtual apps. This works fine. Now I want to take that reusable app (not the solution and it's projects)...
2
by: Ben Dewey | last post by:
Everyone, I am building a new ASP.NET App in 2.0. First off I love it, I can develop things much quicker. One issue that I has been frustrating me alot is the fact that I can't access the...
0
by: Josh | last post by:
I'm dynamicly adding user controls to a datalist in the ItemDataBound event. I'm doing it as I used to prior to 2.0. But now my controls do not appear, any simply answer to why? --...
9
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview...
1
by: =?Utf-8?B?Sm9uYXRoYW4=?= | last post by:
I am trying to add a basic user control to a web site; coming from visual studio 2003 this was extremely easy. I would just add the user control and then add the controls that I want on that user...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
6
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void...
1
by: Shraddha | last post by:
Hi, I am adding some ASP.Net user controls (.ascx file) dynamically on the button click. The user control will get added as many times userhits the button. Now on the click of the submit button, I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.