-1

我的字符串存在于手动创建的 resx 文件中。我正在我的应用程序中创建一个新的 C# Windows 窗体。在表单中,我创建了多个标签控件。我想指出要从资源中设置的控件的文本,而不是在属性面板中对它们进行硬编码。

有没有办法让设计师生成的代码引用我的资源中的字符串?

我有很多要使用 VS 表单设计器创建的表单,并且希望字符串来自资源。

请指教,谢谢

4

1 回答 1

0
//Name Spaces Required

using System.Resources;
using System.Reflection;

// Create the resource manager.
 Assembly assembly = this.GetType().Assembly;

//ResFile.Strings -> <Namespace>.<ResourceFileName i.e. Strings.resx> 
resman = new ResourceManager("StringResources.Strings", assembly);

// Load the value of string value for Client
strClientName = resman.GetString("IDS_MESSAGE");
于 2012-07-12T06:46:58.857 回答