[英]How to rename controls rapidly in Visual Studio 2010?
I´m looking for a way to rename a bunch of controls, which is the fastest way? 我正在寻找一种重命名控件的方法,这是最快的方法吗?
Also, is it possible to change the name prefix of the controls to a custom one like so: 另外,是否可以将控件的名称前缀更改为自定义控件,如下所示:
| | Properties |
属性|
(Name) | (姓名)| TextBox1
TextBox1的
to: 至:
(Name) | (姓名)| txt1
TXT1
as default name when inserting the controls on a form? 在表单上插入控件时的默认名称?
I think the answer to #2 is "no," that is not possible. 我认为#2的答案是“否”,这是不可能的。
As to a fast way to rename controls, you can go into the text view of the form designer and do an incremental search to move from name to name, so you don't have to click each control and then go back to the property grid. 关于重命名控件的快速方法,您可以进入表单设计器的文本视图,并进行增量搜索以从名称移动到名称,因此您不必单击每个控件然后返回属性网格。
A bit more intuitive would be to use the Document Outline pane. 使用文档大纲窗格会更直观。 This is a much faster way to move from control to control and you can rename them in-place instead of going to the property grid.
这是从控件移到控件的更快的方法,您可以就地重命名它们,而不用转到属性网格。 It also has the advantage that you can see by the selection indicator in the designer which control you have selected in the document outline and vice versa.
它还具有的优点是,您可以通过设计器中的选择指示器看到在文档大纲中选择的控件,反之亦然。
By default, navigate to View -> Other Windows -> Document Outline
. 默认情况下,导航至
View -> Other Windows -> Document Outline
。
Here is a screenshot. 这是屏幕截图。 I know you are using VS2010 and this is VS2012, but it works the same way:
我知道您使用的是VS2010,而这是VS2012,但其工作方式相同:
"Replace in Files" which can be found by shift+ctrl+H would be the easiest way to rename all "TextBox" to "txt". 通过shift + ctrl + H可以找到“在文件中替换”是将所有“文本框”重命名为“ txt”的最简单方法。
As for the second point, you could either hand-code the controls to use your prefix or write some kind of Visual Studio add-in that would do the translation for you would be the approach I'd take. 关于第二点,您可以手动编码控件以使用前缀,也可以编写某种Visual Studio加载项来为您完成翻译,这就是我所采用的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.