creating textfields
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: creating textfields

  1. #1
    Join Date
    Sep 2009
    Posts
    15

    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.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,092

  3. #3
    Join Date
    Mar 2011
    Location
    London
    Posts
    54

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center