在VS表单设计器中从Resources分配控件文本

时间:2012-07-12 06:43:16

标签: c#

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

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

我有很多形式可以使用VS form desinger创建,并希望字符串来自资源。

请指教, 谢谢,

1 个答案:

答案 0 :(得分: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");