I’m building a “4 in a row” game, Which the user is prompt to choose the number of rows and columns. with that chosen param of the user, im allocating the space by:
‘m_PictureBoxsMatrix = new PictureBox[NumberOfRows, NumberOfColumns]’
but during the game, the player can change the game properties to a new board size aka new NumberOfRows and new NumberOfColumns.
So after the player changes the board size, I need to reallocate the space.
Am I right ?
The problem is after I’m reallocating the space with
‘m_PictureBoxsMatrix = new PictureBox[NumberOfRows, NumberOfColumns]’ with the new changed parameters. The actual user interface board doesn’t change.
please notice that ‘m_PictureBoxsMatrix = new PictureBox[NumberOfRows, NumberOfColumns]’ is in the UI side and it should be changed accordingly
Since you are using multiple controls, you will indeed need to recreate the controls. Creating a new array will help your code, but won’t change at all the controls in the form’s
Controlscollection. The simplest process is either to recreate the form completely, else empty out the controls (remembering toDispose()each), and re-create from scratch, adding eachPictureBoxto both the array (m_PictureBoxsMatrix) and to the UI.Controls.Add(...)).