解决方案 »

  1.   

    你这样太麻烦,不如在后台 根据数据长度   往前台输入TextBox,至于如何 显示  看你的布局了。这样就不用 在cs里一个一个的写
    textbox1.text 了
      

  2.   

    你的意思是动态创建textbox,直接赋值,是这个意思吗, 
      

  3.   


                int i= 1;
                while (i < 4)
                {
                    string str = string.Format("textBox{0}",i);
                    FieldInfo frild = this.GetType().GetField(str, BindingFlags.Instance | BindingFlags.NonPublic);
                    frild.FieldType.GetProperty("Text").SetValue(frild.GetValue(this), i.ToString(), null);
                    i++;
                }
      

  4.   

    放到List<TextBox>里,循环一下就好了
    不要手动建立100个TextBox对象,太累
      

  5.   

    http://blog.sina.com.cn/s/blog_4b4570920100cah8.html
      

  6.   


         String[] temp = new String[10] { "str0", "str1", "str2", "str3", "str4", "str5", "str6", "str7", "str8", "str9" };
                //方法一: 利用tabIndex 特点简单快捷 但是功能简单 
                //foreach (TextBox control in this.panel1.Controls)
                //{
                //    control.Text = temp[control.TabIndex];
                    
                //}            
                //方法二: 查找所有控件
                for (int i = 1; i <11; i++)
                {
                    string _box = "textBox" + i.ToString();
                    if (this.findControl(this, _box) != null)
                    {
                        TextBox tb = (TextBox)this.findControl(this, _box);
                        tb.Text =temp[i-1];
                    }
                } 
                   }       
            //<summary>
            /// 在winform中查找控件
            ///</summary>
            ///<param ></param>
            ///<param ></param>
            ///<returns></returns>
            private System.Windows.Forms.Control findControl(System.Windows.Forms.Control control, string controlName)
            {
                System.Windows.Forms.Control c1;
                foreach (System.Windows.Forms.Control c in control.Controls)
                {
                    if (c.Name == controlName)
                    {
                        return c;
                    }
                    else if (c.Controls.Count > 0)
                    {
                        c1 = findControl(c, controlName);
                        if (c1 != null)
                        {
                            return c1;
                        }
                    }
                }
                return null;
            }
      

  7.   

    for(int i = 0;i < temp.Length;i++) xxx.Controls["textBox" + (i+1)].Text=temp[i]
      

  8.   

    用BinaryWriter封装成字节。 byte[] buffer = null;
                using (MemoryStream mem = new MemoryStream())
                {
                    BinaryWriter writer = new BinaryWriter(mem);
                    writer.Write(12);  
                    writer.Write(13.1f);
                    writer.Write('c');
                    buffer = mem.ToArray();
                    mem.Close();
                }
      

  9.   

    var temp = new string[100];
                Enumerable.Range(1, temp.Count())
                    .Select(x =>
                    {
                        var control = this.Controls.Find("textbox" + x) as TextBox;
                        if (control != null) control.Text = temp[x - 1];
                    });