[Solved] How do I load my array into multiple text boxes? [closed]


Say you have four numbers in that array. If you have a definitive number of indices, 4 of them, you have to have four TextBox objects.

    List<String> = new List<String>();
    foreach (int myInt in myArray)
    {
        List.add(myInt.ToString());
    }

Then in the main class, or runtime:

TextBox1.Text = List.get(0);
TextBox2.Text = List.get(1);
TextBox3.Text = List.get(2);
TextBox4.Text = List.get(3);

Modify for more numbers if needed 😉

EDIT:

    int randCheck = 0;

    Random rand = new Random();

    int[] powerball5 = new int[5];



    for (int i = 0; i < powerball5.Length; )
    {
        randCheck = rand.Next(0, 60);

        while (!(powerball5.Contains(randCheck)))
        {
            powerball5[i] = randCheck;
            var textBox = this.Controls.Find("textBOX" + i, true) as TextBox;
            textBox.Text = powerball5[i].ToString();
            i++;
        }


    }

Make sure you have textBOX(1-5)!

7

solved How do I load my array into multiple text boxes? [closed]