-
creating textfields
Hi
I have this code.
Code:
string[] cores;
cores = new string[3];
cores[0] = "vermelho";
cores[1] = "verde";
cores[2] = "azul";
foreach (string cor in cores)
{
MessageBox.Show (cor);
}
how can it makes an text field for each item and so put each in a diferente text field?
thanks
-
Re: creating textfields
-
Re: creating textfields
Code:
using System.Windows.Forms;
namespace RedBully
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Create array
string[] cores;
cores = new string[3];
cores[0] = "vermelho";
cores[1] = "verde";
cores[2] = "azul";
for (int i=0; i<cores.Length; i++)
{
//Get required string
string cor = cores[i];
//Create the text box and stick in the text
TextBox tb = new TextBox();
tb.Text = cor;
//Position the text box on the form
tb.Top = i * tb.Height;
//Add the textbox to the form
this.Controls.Add(tb);
}
}
}
}