如何快速命名多个控件?

编程入门 行业动态 更新时间:2024-10-15 02:30:12
本文介绍了如何快速命名多个控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的项目中有很多图片框(300图片框),我想把这个图片框命名为: PictureBox1_75 PictureBox2_75 PictureBox3_75 ...如果有一个地方我可以选择所有名称并使用ctrl + H更改它,那将是如此简单吗?有一个简单的方法吗?

解决方案

int i = 0 ; foreach (控制ctrl this .Controls) { if (ctrl PictureBox) { i ++; ctrl.Name = picBox + i; } }

我没有试过这个,但这应该可行。!!

我没有听到任何支持你请求的IDE,但你可以轻松地在BASH(bourne-again shell)中执行此操作。 假设您的源代码文件是全部* .cs:

ls * .cs |读取 do sed -i.bak的/ Picture \([0-9] * \)_75 / picBox \1 / g'

完成

我建议你看一下在文本处理中非常有用的sed实用程序。 /> 另一点,如果你想在目录及其子目录中搜索* .cs文件,最好使用

查找。 -name* .cs

而不是ls * .cs。 使用shell脚本编写生活更容易:)

i have many picture box in my project ( 300 picture box ) and i want to name all this picture box something like this : PictureBox1_75 PictureBox2_75 PictureBox3_75 ... it would be so easy if there's a place where i can select all the names and change it by using ctrl+H , is there's an easy way to do so ??

解决方案

int i=0; foreach(Control ctrl in this.Controls) { if(ctrl is PictureBox) { i++; ctrl.Name = "picBox" + i; } }

I haven't tried this, but this should work.!!

I haven't heard any IDE that supports your request, but you can do this in BASH(bourne-again shell) easily. Assuming that your source code files are all *.cs:

ls *.cs | while read a do sed -i.bak 's/Picture\([0-9]*\)_75/picBox\1/g'

a done

I recommend you to look at sed utility which is very useful in text processing. Another point, if you like to search for *.cs files in a directory and its sub-directories, better to use

find . -name "*.cs"

instead of "ls *.cs". Life is easier with shell scripting :)

更多推荐

如何快速命名多个控件?

本文发布于:2023-11-27 23:17:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639998.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   控件   快速

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!