Windows窗体应用程序中的资源 [英] Resources in a windows form application

查看:80
本文介绍了Windows窗体应用程序中的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。



我想在visual studio 2008上创建一个Windows窗体应用程序。

这是我第一次。



我想要两种语言(法语和英语)所以我创建资源文件,但我不知道如何使用它。



如何在代码中使用资源文件?



谢谢

解决方案

简而言之,资源文件用于存储从文本到图像的内容。资源文件可以定位到不同的区域设置。您基本上可以拥有您希望支持的每种区域设置(或语言)的资源文件。在你的情况下,你需要两个,一个用于英语,一个用于法语。



这是一个MSDN教程,逐步描述该过程: http://msdn.microsoft.com/en-us/library/y99d1cd3(v = vs.100).aspx [ ^ ]


您实际上不仅需要创建资源。您必须在一种文化中进行所有开发,并将所有需求放在资源中。其他文化的资源应放在仅限资源的附属程序集中。它们应放在名为bu culture的子目录中。这样,只要您更改了线程的文化和UI文化,就会使用 fallback 进程自动(重新)将资源加载到所需的文化或最近的文化。



从这里开始:

http: //msdn.microsoft.com/en-us/library/ff647353.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/aa292205%28v=vs.71%29.aspx [ ^ ]。



另见我过去的答案:

winform .net 中的全球化/本地化问题[ ^ ],

<一个hforms =http://www.codeproject.com/Answers/446585/globalization-in-winforms#answer1> winforms中的全球化 [ ^ ]。



-SA

Hello.

I want to create a windows form application on visual studio 2008.
It is my first time.

I want to have two languages (french and english) so I create resources files but I don't know how to use it.

How can I use the resources files in my code?

Thank you

解决方案

In short, resource files are used to store things, from text to images. Resource files can be targeted to different locales.You would essentially have a resource file for every locale (or language) you wish to support. In your case, you'd need two, one for English and one for French.

Here's an MSDN tutorial describing the process step-by-step: http://msdn.microsoft.com/en-us/library/y99d1cd3(v=vs.100).aspx[^]


You actually need to create not just resources. You have to do all the development in one culture, and put all you need in resources. Resources for other cultures should be placed in the special resource-only satellite assemblies. They should be placed on subdirectories named bu cultures. This way, as soon as you change culture and UI culture of your thread, resources will be automatically (re)loaded to required culture or the nearest found culture, using the fallback process.

Start here:
http://msdn.microsoft.com/en-us/library/ff647353.aspx[^],
http://msdn.microsoft.com/en-us/library/aa292205%28v=vs.71%29.aspx[^].

See also my past answers:
globalization/localization problem in winform .net[^],
globalization in winforms[^].

—SA


这篇关于Windows窗体应用程序中的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆