Q

How do you assign an image dynamically?

I am a user control developer. I use the ToolBoxBitMap attribute to assign an image to my control. But all the examples need hard coding of the image path. This is creating problems if the user deploys the DLL to a different location. Could you please tell me how to assign the image dynamically? I am using VB.NET.
Instead of assigning the toolbox bitmap manually, simply do the following:

  1. Rename the bitmap to the same first name as the control.
  2. Add the toolbar bitmap to the solution.
  3. Select the bitmap in the solution.
  4. In the bitmap properties, set the Build Action to Embedded Resource.
  5. In the bitmap properties, set the Custom Tool Namespace to the same namespace your control uses.

Visual Studio .NET will automatically find the bitmap when you add your control to the toolbox.

This was first published in May 2003

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close