santiago haro

santiago haro

  • NA
  • 16
  • 877

How do i refer to this textbox if it dosnt exist yet?

Oct 15 2018 1:09 PM
Hi, i am creating this button where when you click it creates a new textbox under the last one, is it to save dates and stuff like that, but i am having a problem refering to saving the txtbox.text since i dont know how to refer to it.
 
Here is the code:
 
int tb = 0;
private void button12_Click_1(object sender, EventArgs e)
{
TextBox ls = new TextBox();
string tB = tb.ToString();
string op = (tb - 1).ToString();
string ip = (ls.Name + tB).Text;
int t = 0;
File.Create("fechas" + tB + ".txt");
File.WriteAllText("fechas" + (tb - 1) + ".txt",ip );
ls.Name = "ls" + tB;
ls.Location = new Point(textBox1.Location.X, textBox3.Location.Y + t);
ls.Multiline = true;
ls.BorderStyle = textBox3.BorderStyle;
ls.Size = textBox3.Size;
ls.BackColor = textBox3.BackColor;
this.Controls.Add(ls);
textBox3.Location = new Point(textBox3.Location.X, textBox3.Location.Y + 50);
button12.Location = new Point(button12.Location.X, button12.Location.Y + 50);
t = t + 50;
}
 
I highlighted in yellow what i have wrong, do some one know how to refer to the textbox.text and at the same time changing the name that you are refering to.
Thanks for reading, i will be looking forward for your answers.

Answers (1)