Hi,
I am creating a program on behalf of my company and am stuck in one particular matter. I am fairly new to C#.
At the moment I am creating a textbox, label and a button at the push of a diffrent button with the following code.
TextBox textBox6 = new TextBox();
textBox6.Location = new Point(260, 120);
textBox6.Size = new Size(42, 20);
textBox6.TextChanged += new System.EventHandler(textBox6_TextChanged);
this.Controls.Add(textBox6);
Label label11 = new Label();
label11.Location = new Point(990, 120);
label11.Size = new Size(0, 13);
this.Controls.Add(label11);
Button button2 = new Button();
button2.Location = new Point(860, 120);
button2.Size = new Size(40, 20);
button2.Text = "Add";
button2.Click += new System.EventHandler(button2_Click);
this.Controls.Add(button2);
This all works fine however I need to be able to preform calculations using the textbox and label at the push of the recently created button for which I am using the following code. (I will change the Variable names to Varaible 1..2...3 to avoid confusion)
Variable1 = Convert.ToDecimal(Variable2 * Variable3);
Control[] ctrls = Controls.Find("textBox6", false);
for (int i = 0; i < ctrls.Length; i++)
{
TextBox textBox6 = (TextBox)ctrls[0];
Variable4 = Variable5 * Convert.ToDecimal(textBox6.Text);
}
Variable6 = Convert.ToDecimal(Variable1 * Variable4);
ctrls = Controls.Find("label11", false);
for (int i = 0; i < ctrls.Length; i++)
{
Label label11 = (Label)ctrls[0];
label11.Text = Convert.ToString(Variable6 + Variable7);
windowTotal1.Window2 = Convert.ToDecimal(label11.Text);
}
This should of given me a finished decimal in Label11, I think the problem is having to find the controls generated. Any help is more than welcome and thanked in advance.