Resolved How to set a ToolstripButton Image

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
151
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...

chrisjlocke1

Member
Joined
Apr 12, 2022
Messages
21
Programming Experience
10+
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.
 

chrisjlocke1

Member
Joined
Apr 12, 2022
Messages
21
Programming Experience
10+
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

chrisjlocke1

Member
Joined
Apr 12, 2022
Messages
21
Programming Experience
10+
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.
 

chrisjlocke1

Member
Joined
Apr 12, 2022
Messages
21
Programming Experience
10+
Do you mean this?
They're just voting buttons - so if I say sometjhing complete pants, someone can downvote it.

1653778219283.png
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,617
Location
Norway
Programming Experience
10+
You can upvote/downvote posts, and post can be sorted by votes:
1653781439759.png
 
Top Bottom