我想一下初始化许多个menuitem
是这样写的
for (int i = 0 ; i <10 ; i++)
{
string temp = "menuitem" + i.tostring();
this.temp.Index = 0;
this.temp.Text = "temp";
}可是不行那,好像this不能根个变量哪位解答一下啊
是这样写的
for (int i = 0 ; i <10 ; i++)
{
string temp = "menuitem" + i.tostring();
this.temp.Index = 0;
this.temp.Text = "temp";
}可是不行那,好像this不能根个变量哪位解答一下啊
你这相当于动态赋值了。
可能不行哦~
还有你的temp是string的,怎么有index和text啊?
menuitem1有了定义了
他有这个index和text的
那你还定义一个同名的变量把它盖了?
而且方法本身就没对
用foreach(aaa i in bbb){i.Index = 0;.....}不是容易的多么
想批量写他们的属性,
比如:
menuitem1.text = 1;
menuitem2.text = 2;
...........
不过Winform我没搞过,这东西要是有findcontrol()方法的话,可以利用一下。