aliwishstar
سه شنبه 18 تیر 1392, 21:35 عصر
با سلام خدمت همه دوستان و اساتید.
من قطعه کدی را به صورت زیر نوشتم.حالا نیاز دارم که در button2_Click به آرایه textbox که به صورت داینامیک ساخته می شود(txt[i]) به محتویات آن دسترسی داشته باشم.
لطفا راهنمایی کنید.مرسی
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication21
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int c = 0;
int x = 20;
private void button1_Click(object sender, EventArgs e)
{
string s = textBox1.Text;
foreach (char z in s)
{
c = c + 1;
}
TextBox [] txt=new TextBox [c];
for (int i = 0; i < c; i++)
{
txt[i] = new TextBox();
txt[i].Location = new Point(x, 20);
txt[i].Width = 50;
txt[i].Height = 30;
txt[i].Text = s[i].ToString();
this.Controls.Add(txt[i]);
x = x + 70;
}
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
من قطعه کدی را به صورت زیر نوشتم.حالا نیاز دارم که در button2_Click به آرایه textbox که به صورت داینامیک ساخته می شود(txt[i]) به محتویات آن دسترسی داشته باشم.
لطفا راهنمایی کنید.مرسی
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication21
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int c = 0;
int x = 20;
private void button1_Click(object sender, EventArgs e)
{
string s = textBox1.Text;
foreach (char z in s)
{
c = c + 1;
}
TextBox [] txt=new TextBox [c];
for (int i = 0; i < c; i++)
{
txt[i] = new TextBox();
txt[i].Location = new Point(x, 20);
txt[i].Width = 50;
txt[i].Height = 30;
txt[i].Text = s[i].ToString();
this.Controls.Add(txt[i]);
x = x + 70;
}
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}