Ask the Expert

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: