Visual Studio 2010通过Designer.cs更改控件名称 [英] Visual Studio 2010 Changing Control Names via Designer.cs
本文介绍了Visual Studio 2010通过Designer.cs更改控件名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试通过代码编辑器中的form.designer.cs代码来更改控件的属性.但是每次我更改诸如This.Control.Name = "Whatever";
之类的属性,然后当我返回表单设计器并检查该属性时,它都不会改变,并且当我返回到代码编辑器时,该属性又恢复为原始属性. >
我怎样才能解决这个问题?我做错什么了吗?
Hey guys,
I am trying to change properties of controls via code throughform.designer.cs in the code editor. But every time I change a property like This.Control.Name = "Whatever";
and then when i go back to the forms designer and check the property, it does not change and when I go back to the code editor the property reverts back to the original.
How can I fix this? Am I doing something wrong?
推荐答案
查看文件顶部.您应该会看到类似的内容
//<自动生成的>
//此代码是由工具生成的.
//
//对此文件所做的更改可能会导致错误的行为,如果
//重新生成代码.
//</自动生成的>
Look at the top of the file. You should see something like this
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
*.designer.cs文件由VS自动重新生成,因此您的更改将丢失.请勿编辑* .designer.cs文件.
在普通代码窗口中,右键单击控件的名称,从上下文菜单中突出显示Refactor
,然后单击<code>
Rename.输入新名称,然后按回车键.
工作已完成.
The *.designer.cs file is regenerated by VS automatically so your changes will be lost. DO NOT edit the *.designer.cs file.
In the normal code window, right click on the name of the control, from the context menu highlightRefactor
then click<code>
Rename. Type in the new name and hit return.
Job done.
这篇关于Visual Studio 2010通过Designer.cs更改控件名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文