Right-Click the Project and select Properties. Go to the Resources tab. Add
a file resource. Then you can access it in the app via
Properties.Resources.Resourcename

Signature
HTH,
Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
Thanks! Do I need to do this for each file/locale, or just for the base
file?
Greg
-----Original Message-----
From: Kevin Spencer [mailto:unclechutney@nothinks.com]
Posted At: January 16, 2008 10:42 AM
Posted To: microsoft.public.dotnet.framework.windowsforms
Conversation: Resources in C#
Subject: Re: Resources in C#
Right-Click the Project and select Properties. Go to the Resources tab.
Add a file resource. Then you can access it in the app via
Properties.Resources.Resourcename
--
HTH,
Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
> Can someone help me using resources in C#/.NET 2005?
>
> I've found numerous examples on the internet. They all seem to refer
> to resources files ending in ".resource". why? When I add a new
> resource file, the filetypes are ".resx". Or some others want me to
use resgen..
> I'd rather stay out of the command prompt, and I'm sure it must be
> possible to do everything through the IDE.
[quoted text clipped - 9 lines]
> Thanks,
> Greg
Steven Cheng[MSFT] - 17 Jan 2008 03:47 GMT
Hi Greg,
The way Kevin mentioned can help you add resource into the project's main
resource file. You can also add your own resx file into project and read
resource from them in code. Just like what you do in your first reply:
** add a new resx file into project
** add resource items into the resx file
** use ResourceManager to retrieve resource items from it.
The problem that you didn't get anything is due to the following reason:
For .NET C# project, VS project will use project name as its "default
namespace", therefore, if you add a certain resx file into the project,
suppose "StringResource.resx" and the project name is
"WindowsFormsApplication1", the full name of the resource file is
"WindowsFormsApplication1.StringResource" rather than "StringResource"
e.g.
====================
private void button1_Click(object sender, EventArgs e)
{
ResourceManager rm = new
ResourceManager("WindowsFormsApplication1.StringResource",
typeof(Form1).Assembly);
string str1 =rm.GetString("String1");
MessageBox.Show(str1);
}
=====================
You can try it on your side to see whether it works.
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Greg" <thefish@nospam.nospam>
>References: <000901c85850$9f687470$6e6f100a@ncr.dfompo.ca>
<uTvi2YFWIHA.1184@TK2MSFTNGP04.phx.gbl>
>Subject: Re: Resources in C#
>Date: Wed, 16 Jan 2008 16:08:58 -0500
>Thanks! Do I need to do this for each file/locale, or just for the base
>file?
[quoted text clipped - 39 lines]
>> Thanks,
>> Greg
Kevin Spencer - 17 Jan 2008 12:31 GMT
Hi Greg,
Sorry, I didn't see that you're using Localization. Visual Studio's Resource
Designer can be used for localized resources as well. The following article
explains how:
http://technet.microsoft.com/en-us/library/aa992030.aspx

Signature
HTH,
Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
> Thanks! Do I need to do this for each file/locale, or just for the base
> file?
[quoted text clipped - 39 lines]
>> Thanks,
>> Greg