在VS表单设计器中从资源中分配控件的文本



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

有没有一种方法可以让设计器生成的代码引用我的资源中的字符串?

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

请告知:,谢谢,

//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");

最新更新