I’ve created a dimensional array using two ‘for’ loops, and as each inner loop completes, I’d like those values to go into textboxes on a windows form. (I realize that the values will be overwritten each time, with just the values from the final outer loop showing at the end.)
The comments in the code show what I’ve been trying to get to work.
Thanks!
if (IsValidData()) { int Columns = 5; int Rows = Convert.ToInt32(txtNumbDrawings.Text); int[,] ball = new int[Columns, Rows]; for (int i = 0; i < Rows; i++) { List<int> ballsList = new List<int>(); int[] txtBall = new int[Columns]; for (int j = 0; j < Columns; j++) { Random number = new Random(); ball[i, j] = number.Next(1, 70); // prevent duplicate numbers while (ballsList.Contains(ball[i, j] )) { ball[i, j] = number.Next(1, 70); } ballsList.Add(ball[i, j]); /************************************************* * how do I get the current ball value * into a listbox on a form? * * listboxes are named lstBall1, lstBall2, etc... * * I was trying something like: * * TextBox[] txtBall = new TextBox[5]; * for (int i = 0; i < 5; i++) * { * txtBall[i + 1].Text = ball[i, j].ToString(); * } *************************************************/ } ballsList = null; } }