External resources and forms designer

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Hello,

I created a class library project to store my images resources.
In another project (windows app) I just want to set an image for a
toolstripbutton.
Where can I write this simple line of code :
ToolStripButton1.Image = ExternalResource.ButtonImage
So that I can see the image in design mode ? And so that Visual Studio
won't create a copy of my image in the form's resx file ?
 
Hi,

You just need to add a Resource File to your ClassLibrary project.
Open the resources designer (just double-click on the resx file) and change
the 'Access Modifier' property in the designer (located on the top of the
designer-> you have a combo box and you can switch from private to public).

Then Add a reference to your classlibrary from your windows forms app and
you can code something like this:
pictureBox1.Image = ExternalResources.Image1;
(assuming you have declared the 'using' reference).

Frédéric Queudret
CTO Mpoware
http://www.mpoware.com/
 
Dans : Frédéric Queudret écrivait :
Hi,
Hello,

You just need to add a Resource File to your ClassLibrary project.
Open the resources designer (just double-click on the resx file) and
change the 'Access Modifier' property in the designer (located on the
top of the designer-> you have a combo box and you can switch from
private to public).

Yes, that's what I did
Then Add a reference to your classlibrary from your windows forms app
and you can code something like this:
pictureBox1.Image = ExternalResources.Image1;
(assuming you have declared the 'using' reference).

Yes, my problem is where to write this.
I program with vb.NET
If I write in the constructor, the image won't appear in Design mode.
If I write in the generated code, it appears, but if I make a change and
the code is generated again, Visual Studio makes a copy of my image in
the form's resx file and change my code.

I will simply keep theses resources in the same assembly. I need some
external resources elsewhere but it is not so important here.
 
Back
Top