简体   繁体   English

有没有办法一次性改变winform标签名称?

[英]Is there any way to mass-change winform label names at one time?

I have a form with about ~400 Labels with random names such as '1', '00a', '241c' '1251', etc. I want to give them new names that increment, such as 'lbl001', 'lbl002', 'lbl003'... 我有一个大约有400个标签的表格,随机名称如'1','00a','241c''1251'等。我想给它们增加新名称,例如'lbl001','lbl002' ,'lbl003'......

Changing them manually takes several seconds for each one. 手动更改它们需要几秒钟。 Is there a way to speed this up or handle all of them at once? 有没有办法加快速度或同时处理所有这些?

You can create a script to iterate over all declarations of Labels in the Form.Designer.cs and replace each name it finds with a the value of the loop's counter + a prefix. 您可以创建一个脚本来迭代Form.Designer.cs中所有标签声明,并将它找到的每个名称替换为循环计数器+前缀的值。

You can find Label declarations using Regular Expressions, and then iterate through the list of matches. 您可以使用正则表达式找到Label声明,然后遍历匹配列表。

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

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