简体   繁体   English

重命名后,ResFor资源似乎在WinForms表单中被忽略

[英]ResX resources seem ignored in WinForms form after rename

I have renamed my class Form1 to Form2 . 我已将我的类Form1重命名为Form2 After this refactoring, I noticed the form had two .resx files associated with it. 在重构之后,我注意到表单有两个与之关联的.resx文件。 One called Form1.resx (containing the actual child control positioning data and translations) and one called Form2.resx. 一个名为Form1.resx(包含实际的子控件定位数据和翻译),一个名为Form2.resx。

I have fixed this manually by removing the Form1.resx file and copy & pasting the contents of that file to Form2.resx. 我已通过删除Form1.resx文件手动修复此问题,并将该文件的内容复制并粘贴到Form2.resx。

However, the designer layouts all the controls on the topleft. 然而,设计师布置了topleft上的所有控件。 This indicates that it ignores the settings in the .resx file. 这表示它忽略.resx文件中的设置。

How to make the WinForms designer respect the .resx file? 如何让WinForms设计师尊重.resx文件?

Open the .resx file. 打开.resx文件。 Find the xml element 找到xml元素

<data name="&gt;&gt;$this.Name" xml:space="preserve">
    <value>Form1</value>
</data>

and change the value element content to the name of the new form class name (in this case Form2 ) 并将值元素内容更改为新表单类名称的名称(在本例中为Form2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM