Bitmap displayed in ToolBox of Visual Studio for a control

C

Charles Zhang

I created a class that derives from DbConnection class(in turn derives
from Component Class).

I specified a ToolboxBitmapAttribute for the class like:

[ToolboxBitmap(typeof(SpeedyDbConnection),
"Bitmaps.SpeedyDbConnection.bmp")]

Correct bitmap is shown in the component tray of a form. However, the
default bitmap (not the one I specified) is shown on the toolbox.

According to the following link, specify the ToolboxBitmap is all I need
to do.
http://msdn2.microsoft.com/en-us/library/4wk1wc0a(vs.80).aspx

But the document for ToolboxBitmapAttribute class says:
"Allows you to specify an icon to represent a control in a container,
such as the Microsoft Visual Studio Form Designer.". I am not sure if
"ToolBox" is a kind of container.


So I created my own ToolBoxItem class ( a class that derives from
ToolBoxItem) and specify the "BitMap" property using my own bitmap. I
debugged into my own ToolBoxItem class when I added the component into
the toolbox, the BitMap property was changed as I am expecting, but the
toolbox is still showing wrong bitmap.

I would like someone to point out what I am doing wrong here.

Thanks

Charles Zhang
 
L

Linda Liu [MSFT]

Hi Charles,

I performed a test based on your description and did see the same thing as
you did.

I create a Winforms application project and add a component to the project.
I add a ToolboxBitmapAttribute to the component. The following is the code
of the component.

[ToolboxBitmap(typeof(Button))]
public partial class class1:Component
{
...
}

After I build the project, a tab with the same name as the project is
populated automatically in the Toolbox and the component appears under this
tab. The bitmap next to the component is the default bitmap.

I also performed a test adding the component to the Toolbox manually, and
see the bitmap next to the component is correct at this time. It means that
the bitmap specified by the ToolboxBitmapAttribute isn't shown in
auto-generated items.

FYI, to do this, right-click on the Toolbox and select 'Choose Items'. In
the 'Choose Toolbox Items' dialog, switch to the '.NET Framework
Components' tab page and click the 'Browse' button to specify the assembly
containing the component. After I select the assembly, the component name
appears in the list box and I select the checkbox before the component.
Press OK button to close the dialog. The new added component has a correct
bitmap.

I have searched in our inner database. I find that this behavior is by
design for performance reasons. The relevant documentation should have
pointed it out. A good news is that our product team has considered this as
they prepare the next release of the documentation.

We are sorry for the inconvenience the documentation brings to you!

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Charles Zhang

Thank you very much for your response.

However, I am having problem to have the bitmap of the control to show
up correctly even I added the control to the toolbox manually as I
mentioned in the first item.

After spending hours, I find it is a problem with Visual Studio. Looks
like visual studio is caching the available controls and bitmaps for an
given assembly.

I deleted the assembly from GAC and restarted my computer, the controls
of the assembly are still available for choosing. I am lost about why
Visual Studio is doing that.

By the way, when I installed the assembly onto another computer, the
correct bitmaps are shown up in the toolbox for the controls.

Thanks

Charles Zhang







Hi Charles,

I performed a test based on your description and did see the same thing as
you did.

I create a Winforms application project and add a component to the project.
I add a ToolboxBitmapAttribute to the component. The following is the code
of the component.

[ToolboxBitmap(typeof(Button))]
public partial class class1:Component
{
...
}

After I build the project, a tab with the same name as the project is
populated automatically in the Toolbox and the component appears under this
tab. The bitmap next to the component is the default bitmap.

I also performed a test adding the component to the Toolbox manually, and
see the bitmap next to the component is correct at this time. It means that
the bitmap specified by the ToolboxBitmapAttribute isn't shown in
auto-generated items.

FYI, to do this, right-click on the Toolbox and select 'Choose Items'. In
the 'Choose Toolbox Items' dialog, switch to the '.NET Framework
Components' tab page and click the 'Browse' button to specify the assembly
containing the component. After I select the assembly, the component name
appears in the list box and I select the checkbox before the component.
Press OK button to close the dialog. The new added component has a correct
bitmap.

I have searched in our inner database. I find that this behavior is by
design for performance reasons. The relevant documentation should have
pointed it out. A good news is that our product team has considered this as
they prepare the next release of the documentation.

We are sorry for the inconvenience the documentation brings to you!

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu [MSFT]

Hi Charles,

Thank you for your reply.

If possible, could you send me your sample project that could just
reproduce the problem for further discussion? To get my actual email
address, remove 'online' from my displayed email address.

Thanks for your cooperation!

Sincerely,
Linda Liu
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top