In a form the user can choose the amount of images that he can by, for each image I must create a texbox to put the URL of each image. It will determine this amount through NumericUpDown
, so I have to read the value of it and apply it to the function to create the amount of textbox:
I tried this way:
private void criaImg(TextBox[] txt, int X, int Y, int qnt)
{
int cont = 0;
while (cont < qnt)
{
txt[cont] = new System.Windows.Forms.TextBox();
txt[cont].Location = new System.Drawing.Point(X, Y + Y);
txt[cont].Name = "img" + cont;
txt[cont].Size = new System.Drawing.Size(100, 20);
txt[cont].TabIndex = 1;
cont++;
}
}
private void qntImg_ValueChanged(object sender, EventArgs e)
{
TextBox[] array = new TextBox[(int)qntImg.Value];
criaImg(array, 20, 30, (int)qntImg.Value);
}
Maybe it would be simpler to put a ADD
button and when the user clicks it it creates a textbox but it does not work, how do I do it?