Имеется код, который делает на форме2 100 текстбоксов. Боксы заполняются '+', затем количество данных плюсов высчитывается для каждой строки. Номер строки и количество плюсов - исходные данные для формы3, на которой будет график Chart. Не пойму, как передать в форму3 данные, чтобы использовать их для графика.
namespace VKR
{
public partial class Form2 : Form
{
public int Nx = 40, Ny = 28;
public int Loc_x = 3, Loc_y = 3, Sw = 35, Sh = 20;
public static int iLimit = 10, iVariable = 10;
public int counter = 0;
public int[] count;
public TextBox[,] tbArray;
public Label[] lbArray_exp;
public Label[] lbArray_V;
public Form2()
{
InitializeComponent();
Create(iLimit, iVariable);
}
public void Create(int lim, int var)
{
tbArray = new TextBox[lim, var];
lbArray_exp = new Label[var];
lbArray_V = new Label[var];
//
for (int i = 0; i < lim; i++, Loc_y += Ny)
{
Loc_x = 3;
//
lbArray_V[i] = new Label();
lbArray_V[i].Name = "label_V" + i;
lbArray_V[i].Text = string.Format("{0}", (i + 1) * 10);
lbArray_V[i].TextAlign = ContentAlignment.TopLeft;
lbArray_V[i].Location = new Point(0, Loc_y);
//
panel3.Controls.Add(lbArray_V[i]);
//
for (int j = 0; j < var; j++, Loc_x += Nx)
{
tbArray[i, j] = new TextBox();
tbArray[i, j].Name = "TextBoxx" + j;
tbArray[i, j].Size = new Size(Sw, Sh);
tbArray[i, j].Location = new Point(Loc_x, Loc_y);
panel1.Controls.Add(tbArray[i, j]);
//
lbArray_exp[j] = new Label();
lbArray_exp[j].Name = string.Format("exp_", j);
lbArray_exp[j].Text = string.Format("Экс.{0}", j + 1);
lbArray_exp[j].TextAlign = ContentAlignment.MiddleRight;
lbArray_exp[j].Location = new Point(Loc_x - 65, 0);
panel2.Controls.Add(lbArray_exp[j]);
}
}
}
private void Form2_Load(object sender, EventArgs e)
{
Button btn = new Button();
//
btn.Name = "btn1";
btn.Text = "Обработать";
btn.Size = new Size(80, 25);
btn.Location = new Point(this.ClientSize.Width - btn.Width - 5, this.ClientSize.Height - btn.Height - 5);
this.Controls.Add(btn);
//
foreach (TextBox tb in panel1.Controls.OfType<TextBox>())
{
tb.KeyPress += textBox_KeyPress;
}
btn.Click += btn1_Click;
}
private void btn1_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3();
//
string[] str = new string[iLimit];
int[] count = new int[iLimit];
//
for (int i = 0; i < iLimit; i++, counter = 0)
{
for (int j = 0; j < iVariable; j++)
{
if (tbArray[i, j].TextLength >1)
{
tbArray[i, j].Text = "+";
}
if (tbArray[i, j].Text == "+")
{
counter++;
}
}
count[i] = counter/iLimit;
}
form3.ShowDialog();
this.Hide();
}
private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != '+' && e.KeyChar != (char)8)
{
MessageBox.Show("ошибка ввода");
e.KeyChar = new char();
}
}
}
}