简体   繁体   English

如何在Visual Studio 2010中快速重命名控件?

[英]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.

相关问题 使用Visual Studio 2010的SharePoint 2010委托控件 - SharePoint 2010 delegate controls with Visual Studio 2010 如何在设计时将控件可见性设置为 false Visual Studio 2010? - How to set a controls visibility to false at design time visual studio 2010? Visual Studio重命名文件夹和控件-可以吗? - Visual Studio rename folder and controls - is it possible? 重命名Visual Studio 2010中的Crystal报表中的部分 - Rename a section in a Crystal Report in Visual Studio 2010 无法重命名Visual Studio 2010项目 - Can't rename Visual Studio 2010 Project visual studio 2010工具箱标准控件缺失 - visual studio 2010 toolbox standard controls missing 禁用 Visual Studio 2010 工具箱控件 - Visual Studio 2010 Toolbox controls disabled Visual Studio 2010:如何重新映射F2以重命名文件而不是打开对象浏览器 - Visual Studio 2010: How Can I remap F2 to Rename File rather than Open Object Browser 如何将控件添加到Visual Studio 2010 Express工具箱中(代码,系统文件等)? - How to Add Controls To The Visual Studio 2010 Express Toolbox (Code, System Files, etc)? 如何使用Visual Studio 2010 asp.net设计视图绝对定位控件? - How can I position controls absolutely using the Visual Studio 2010 asp.net design view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM