RT:
            int[] arr = new int[4] { 4, 3, 2, 1 };
数组里的值 
form 窗体有4个 label 空间 用循环 放值 咋搞? 
好像是用 foreach

解决方案 »

  1.   


            private void button1_Click(object sender, EventArgs e)
            {
                string[] str=new string[] {"AAA","BBB","CCC"};            Label[] lbl = new Label[] { label1,label2,label3 };            for (int i = 0; i < str.Length; i++)
                {
                    lbl[i].Text = str[i];
                }        }
      

  2.   


    int index = 0;
    foreach(Control c in this.Controls)
    {
       if(c is Label && index<arr.Length)
       {
          ((Label)c).Text = arr[index++].ToString();
       }
    }
      

  3.   

    c is Label 可以这样判断???
      

  4.   

    不是控件数组,是遍历控件。2楼的意思是如果控件是Lable并且没超数组长度的话,就把数组的值转成字符类型的赋给lable控件的text属性,应该是没问题的。需要说明一点如果你的lable是直接放在form中这样做是没问题的,如果你的lable是放到了groupbox1之类的容器里foreach的时候就不能用this.controls,就要用groupbox1.controls了。