迭代图片框
如何在 Visual Basic 10 中迭代名为 PictureBox1、PictureBox2 ... PictureBox24 的 PictureBox
How can I iterate through PictureBoxes named PictureBox1, PictureBox2 ... PictureBox24 in Visual Basic 10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该为您的图片框指定有意义的名称,如果您有那么多图片框,您应该将它们放入一个数组中。
除此之外,拥有这么多图片框会损害性能。您可能正在使用它们来绘制单个对象 - 不要这样做!使用一个图片框并在其上绘制所有内容。
但如果您确实愿意,可以迭代父控件的
Controls
集合。其中
parent
是包含图片框的父控件(例如表单)。You should give your
PictureBox
es meaningful names and if you have that many picture boxes you should put them into an array.Apart from that, having that many picture boxes hurts performance. You are probably using them to draw individual objects – don’t do that! Use one picture box and draw everything on it.
But if you really want to, you can iterate the parent control’s
Controls
collection.Where
parent
is the parent control (e.g. the form) that contains the picture boxes.