Resolved How to set a ToolstripButton Image

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
219
Programming Experience
10+
I have an old WindowsForms program that I converted to Net 6.0.

It has some ToolstripButtons that do not display an image although Display style is Image.

Under My Project there is a file named Resources.resX which shows as being empty when I click it.

The usercontrol is defined by three files:
Ctl.vb
Ctl.Designer.vb
ctl.resX

Click on the ctl.resX displays a set of images perfect for the buttons. With names like: ToolStripButton_Bold.Image

I want to use the resX files for the button images

I do not use the resX files for any other purpose.

Questions:

1) In this situation should there be two resX files?

2) Does it make sense to delete the Resources.resx file and move the other resX file under My Project folder and rename it?

3) If not, how should I proceed?
 
Solution
OK, so I created a new project. Hopefully this makes it easier to explain.

If you add in the resx file, you can open it in VS, and export any image you want to reuse. When you add an image to a button, you can only select images already imported into the project.
If you add it locally, you'll get a form .resx file as well as a project resx. I always tend to add to the project, as you never know if you'll reuse an image.

So yes, import the resx file, but only to export the images, and import again as a project resource.
You can then remove the resx file you imported.

Watching that video back didn't make a great deal of sense. Needed a voiceover really! ;)
So I added a toolstrip button, added a...
When you click a button, then 'image' on the properties grid, you can either add a local resource, or a project resource.
If you're going to add a picture that could be used throughout your project, use the project resource.
Icon images are usually 16x16 or 32x32 so relatively small - the difference in your program is quite minimal.
 
Does the local and project resources you mention relate to the two resX files I have?

If so, do I simply import the resX file?
 
OK, so I created a new project. Hopefully this makes it easier to explain.

If you add in the resx file, you can open it in VS, and export any image you want to reuse. When you add an image to a button, you can only select images already imported into the project.
If you add it locally, you'll get a form .resx file as well as a project resx. I always tend to add to the project, as you never know if you'll reuse an image.

So yes, import the resx file, but only to export the images, and import again as a project resource.
You can then remove the resx file you imported.

Watching that video back didn't make a great deal of sense. Needed a voiceover really! ;)
So I added a toolstrip button, added a local image. Thus the form based resx file.
Added another button and a project based image, and showed that resx file. Then showed double-clicking the resx file showed the resources, and allowed you to export them.
 
Solution
Once an image is imported is there any way to delete it?

No big deal, but I imported an image twice and it bug me.
 
Yes, if you double-click the .resx file, then right-click an image, you should see an option to remove it.
If there is a reference to that image, its easy to relink it to the other image.
If you need another screencast, just yell.
 
Thanks. I removed it OK.

With your post above: What is the Zero with angle brackets above and below at the right for?
 
Do you mean this?
They're just voting buttons - so if I say sometjhing complete pants, someone can downvote it.

1653778219283.png
 
If I understand:

Its not for the original poster to say "thanks that really helped" but rather for a third party to say they agree or disagree with your post'
 
You can upvote/downvote posts, and post can be sorted by votes:
1653781439759.png
 
Back
Top