Using "resources" files

  • Thread starter Thread starter Dina Johson
  • Start date Start date
D

Dina Johson

Hi,

I am currently trying to understand how to use resource
files in a VB.NET windows application. I understand the
general concept, but it think there is a detail I am
missing. BTW, the resource file is not used for
Globalization here.

I have a simple form with a button and a textbox. I have
added a .resx file in my project. This is the code that
handles the button click:
Dim rm As New ResourceManager(GetType(Form1))

Me.TextBox1.Text = rm.GetString("2")
// 2 is the name of the string element in
the .resx file

The ".resources" file seems to be generated properly in
the OBJ directory, but when I click on the button, nothing
appear.
What do I miss?


thank you!

Dina
 
Hi,
I have a simple form with a button and a textbox. I have
added a .resx file in my project. This is the code that
handles the button click:
Dim rm As New ResourceManager(GetType(Form1))

Me.TextBox1.Text = rm.GetString("2")
// 2 is the name of the string element in the .resx file

The resource-file associated with the form is a so-called Windows Resource
File. It can't contain string-resources. Well, it can, but the designer will
regenerate the resource file on building and it'll be gone. You need to Add
New Item and add a Resource File. Enter you string in there.

Then, do what you did above. You'll have to modify the
constructor-parameters, I think.
The ".resources" file seems to be generated properly in the OBJ directory,
but when I click on the button, nothing
appear. What do I miss?

If you have several assemblies in your solution and the resource-files are
not in the main assembly (startup-project), you'll have to copy the folders
with resource files into the main assembly's bin/debug directory.
 
Back
Top