简体   繁体   中英

Automatically move all the control properties from a resx file to a designer.cs code file

I have a Form which contains controls whose properties', such as their positions, are defined in a resx file, like so:

Form1.rex:

<data name="textBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 61</value>

And those properties are then retrieved using the following method call:

resources.ApplyResources(this.textBox1, "textBox");

What I want though, is to get rid of this method call as well a the resx file, and directly set the control properties in the designer.cs file , like so:

Form1.Designer.cs:

textBox1.Location = new System.Drawing.Point(15,61);

Of course I could do this manually, but I have a lot of Forms and it would take me a while so I was wondering if there was some way to do this?

I found the solution, for those facing the same issue, what you need to do is simply set the "Localizable" property of the form to false. This will cause all the properties of the different controls to be coded in the designer, and not be dynamically retrieved at runtime from the resource file.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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