How to set a custom bitmap image for a user control in Visual Studio .NET or in Visual Studio 2005 (836667)
The information in this article applies to:
- Microsoft Visual Studio 2005 Professional Edition
- Microsoft Visual Studio 2005 Standard Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
INTRODUCTIONThis step-by-step article describes how to set a custom
bitmap image for a user control. It also describes the specific property settings for the
bitmap image and how to set the image as an icon for the user control. back to the topRequirementsThis
article assumes that you are familiar with the following topic:
How to develop user controls in Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005 The following list outlines the recommended hardware, software,
network infrastructure, and service packs that you need: Microsoft Visual Studio .NET 2003, Visual Studio .NET 2002, or Visual Studio 2005 back to the topCreate a user control- Start Visual Studio .NET or Visual Studio 2005.
- On the File menu, point to
New, and then click Project.
- Under Project Types, click Visual
Basic Projects.
Note In Visual Studio 2005, click Visual
Basic. - Under Templates, click Windows
Control Library.
- In the Name box, type
MyUserControl, and then click OK.
By default, a file that is named UserControl1.vb is
created. By default, the UserControl class is also named UserControl1. back to the topAdd a bitmap file to the user control- On the File menu, click Add New
Item.
- Under Templates, click Bitmap
file.
- In the Name box, type
UserControl1.bmp, and then click
Open.
Note You must use the same name for the bitmap file as the name of the UserControl class that was created in the "Create a user control" section. - Set the Height property and the Width
property of the UserControl1.bmp file to
16.
- Set the Build Action property of the
UserControl1.bmp file to Embedded
Resource. To do this, click Embedded
Resource in the list box that is associated with the Build
Action property.
- In the editor, draw any image.
- On the Build menu, click Build
Solution.
back to the topAdd the user control to the Visual Studio .NET or Visual Studio 2005 Toolbox- In
Solution Explorer, double-click the UserControl1.vb file.
- In the Toolbox, click the General tab, and then do the following, depending on the product version that you have:
- In Visual Studio .NET 2002, right-click the General tab, and then click Customize
Toolbox.
- In Visual Studio .NET 2003, right-click the General tab, and then click Add/Remove
Items.
- In Visual Studio 2005, right-click the General tab, and then click Choose Items.
- Click the .NET Framework Components tab, and then click Browse.
- Locate and then click the
MyUserControl.dll file.
- Click Open, and then click OK.
Notice that the user control is added to the
General tab and that the icon is set to your custom bitmap
image. back to the
topREFERENCESFor more information about user controls, visit the following Microsoft
Developer Network (MSDN) Web sites: back to the top
Modification Type: | Major | Last Reviewed: | 2/28/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbHOWTOmaster kbBitmap kbhowto KB836667 kbAudDeveloper |
---|
|