我可以使用“for”编辑多个控件吗?循环? [英] Can I edit multiples controls with "for" loop ?
本文介绍了我可以使用“for”编辑多个控件吗?循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你知道怎么做这样的事吗
(第一篇文章)如果出现问题则sry ^^)
我尝试了什么:
Hi,
Do you know a way to do something like this
(First post sry if something is wrong ^^)
What I have tried:
for (int i = 0; i < 10; i++){
Textblock-->I<--.Text = "I = " + i;
推荐答案
您可以在数组中添加所有控件,然后使用i
索引该数组并设置Text
属性:
You can add all controls in an array, and then usei
to index that array and set theText
property:
TextBox[] boxes = new TextBox[] {
Textblock1, Textblock2, Textblock3
};
for (int i = 0; i < boxes.Length; ++i) {
boxes[i].Text = string.Format("I = {0}", i);
}
这篇关于我可以使用“for”编辑多个控件吗?循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文