Problem solve Get help with specific problems with your technologies, process and projects.

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.

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.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.