create array of textboxes in code that equate to text boxes on form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ingaivey
    New Member
    • Dec 2009
    • 3

    create array of textboxes in code that equate to text boxes on form

    I have 81 text boxes on a form and would like to create a text array in code that will equate to these boxes on the form. Once I've assigned each text box from the form to the array entry, I'd just like to work with the array - then have the actual text boxes on the form reflect the changes made to the array.
    Is this possible, and if so, how?
    Thanks.
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Code:
    TextBox[81] myTBarray = new TextBox[81];
    TextBox[0] = TextBox1;
    TextBox[1] = TextBox2;
    // And so on

    Comment

    • ingaivey
      New Member
      • Dec 2009
      • 3

      #3
      Yes - thanks.
      I did this - but I was hoping to find a way that if I changed the textbox array in code, that they would automatically update the real textbox's in the form. ( instead of having to explicitly say formtextbox=txt boxarray)
      Thanks for your input though.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        TextBox[14].Text = "My new text";

        You have an array of actual text boxes. Treat the array elements as your textboxes.

        Comment

        • ingaivey
          New Member
          • Dec 2009
          • 3

          #5
          Yes - thanks.
          I realized after I made the last post, that my actual text boxes in the form were being updated from the array.
          (I haven't programmed for several years and have forgotten a lot of stuff!)

          Comment

          Working...