-
April 3rd, 2011, 07:18 PM
#1
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
Last edited by HanneSThEGreaT; April 5th, 2011 at 01:29 AM.
-
April 5th, 2011, 01:29 AM
#2
-
April 6th, 2011, 11:06 AM
#3
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);
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|