none
Array of TextBox !!!

Answers

  • C# dose not support waht called in vb6 Control array

    you can create your array via code like peter answered you now you want to create the array from the form not totally from the code so you can put the textboxs that you want and set its properties

    and in some where at your code write something like



    TextBox[] arrText = new TextBox[] { textBox1, textBox2, textBox3 };

     

    where is the textBox1,etc is the names of your TextBoxs

    Thursday, August 17, 2006 5:28 PM
  • another option to work with TextBoxs through Controls collection


    foreach(Control crl in this.Controls)
    {
    if (crl is TextBox)
    {
    TextBox txt=crl as TextBox;
    Debug.WriteLine(crl.Text);
    }
    }

     

    Thursday, August 17, 2006 5:36 PM

All replies

  • TextBox[] textBoxArray = new TextBox[10];
    Thursday, August 17, 2006 5:04 PM
  • Thanks, but how do i create them on the form not by code, just like VB.
    Thursday, August 17, 2006 5:09 PM
  • C# dose not support waht called in vb6 Control array

    you can create your array via code like peter answered you now you want to create the array from the form not totally from the code so you can put the textboxs that you want and set its properties

    and in some where at your code write something like



    TextBox[] arrText = new TextBox[] { textBox1, textBox2, textBox3 };

     

    where is the textBox1,etc is the names of your TextBoxs

    Thursday, August 17, 2006 5:28 PM
  • If you're looking for some of the features of Control Arrays, check out Getting Back Your Visual Basic 6.0 Goodies for information on how to simulate Control Arrays in .NET.
    Thursday, August 17, 2006 5:31 PM
  • another option to work with TextBoxs through Controls collection


    foreach(Control crl in this.Controls)
    {
    if (crl is TextBox)
    {
    TextBox txt=crl as TextBox;
    Debug.WriteLine(crl.Text);
    }
    }

     

    Thursday, August 17, 2006 5:36 PM
  • thanks, It simulated what I needed.

    Another question: How can i get my columns names from a TableAdapter or any other way that i can get my column'name in VC#2005.

    I'm sorry. I'm new in VC# 2005.

    Thanks

    Thursday, August 17, 2006 8:00 PM
  • Yes you can add an array of TextBox dynamically to the form.

    e.g. -

    Using System.Windows.Forms;
    Using System.Drawing;


    TextBox[] tb = new TextBox[5];

    for(int i = 0, len = tb.length; i < len; i++)
    {
         tb[i] = new TextBox();
         tb[i].Name = "textBox"+i;
         tb[i].Location = new Point(10, 10 * i);
         this.Controls.Add(tb[i]);
    }

    --
    Mukesh Sharma
    Monday, August 24, 2009 9:18 AM
  • You do realise you replied to a THREE YEAR OLD message, right?
    Monday, August 24, 2009 11:35 AM
  • You do realise you replied to a THREE YEAR OLD message, right?

    That had been marked answered!
    Monday, August 24, 2009 11:40 AM