Icons of custom controls in the vs toolbox

Source: Internet
Author: User
Tags bmp image

Sometimes we
When a third-party control is added to the toolbox of vs2005, a custom icon is displayed.

Without any processing, we use the default icon when generating the control and placing it in the toolbox. It looks a little ugly.

How do I customize icons?
The toolboxbitmap attribute is used.
Use toolboxbitmap
Using system. drawing;

First, prepare a BMP file with the same name as your control type.
For example

  1. Public class mywebcontrol: webcontrol
  2. {
  3. }

Type, your BMP file must be
Mywebcontrol.bmp
Now you can use toolboxbitmap
Now

  1. [Toolboxbitmap (typeof (mywebcontrol), "mywebcontrol.bmp")]
  2. Public class mywebcontrol: webcontrol
  3. {
  4. }

Mywebcontrol.bmp is stored in the root directory.
If your
Mywebcontrol.bmp must be referenced in this way in other directories, for example, in the icon
Directory

  1. [Toolboxbitmap (typeof (mywebcontrol), "icon.mywebcontrol.bmp")]

After compilation, drag it to the toolbox to test the compiler.

There are other methods that do not use the toolboxbitmap attribute.
Use a bitmap image (not an icon)
Images, embedded resources) files
For example, if you have a namespace lemongtreecontrol and the custom control is bar.

1: create an image named bar.bmp according to the above image rules and add the image to your project,

2: Set the bar.bmp image setting property generation operation to "embedded resource"

3: note that the namespace of the image must be lemongtreecontrol.

4: If the namespace of the control does not match the default namespace of the project, you must set the bitmap
Move the image to the appropriate subdirectory to match the image. If this method is invalid, you obviously cannot use this technology to implement your custom image. You can use the toolboxbitmap below
Attribute Technology

5: Indicate the icons in the toolbox that I used directly in the root directory.

The above simple technology is used to meet your needs, and you do not need to use toolboxbitmapattribute to generate your type.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.