PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Using "resources" files

Reply

Using "resources" files

 
Thread Tools Rate Thread
Old 25-06-2003, 03:20 PM   #1
Dina Johson
Guest
 
Posts: n/a
Default Using "resources" files


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
  Reply With Quote
Old 25-06-2003, 08:17 PM   #2
Tomas
Guest
 
Posts: n/a
Default Re: Using "resources" files

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.


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off