Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
控制不工作的c#picturebox_C#_Forms_Picturebox_Windows Forms Designer_Maze - Fatal编程技术网

控制不工作的c#picturebox

控制不工作的c#picturebox,c#,forms,picturebox,windows-forms-designer,maze,C#,Forms,Picturebox,Windows Forms Designer,Maze,我正在学习如何在c#中制作递归迷宫的教程。 以下是教程: 我一直在遵循这些步骤,但我无法进一步了解,因为当我运行此代码时,图片框不会像教程中那样显示 这是它们应该制作的部分: private void createNewMaze() { mazeTiles = new PictureBox[XTILES, YTILES]; //Loop for getting all tiles for (int i = 0; i < XTILES;

我正在学习如何在c#中制作递归迷宫的教程。 以下是教程:

我一直在遵循这些步骤,但我无法进一步了解,因为当我运行此代码时,图片框不会像教程中那样显示

这是它们应该制作的部分:

private void createNewMaze()
    {
        mazeTiles = new PictureBox[XTILES, YTILES];
        //Loop for getting all tiles
        for (int i = 0; i < XTILES; i++)
        {
            for (int j = 0; j < YTILES; j++)
            {
                //initialize a new PictureBox array at cordinate XTILES, YTILES
                mazeTiles[i, j] = new PictureBox();
                //calculate size and location
                int xPosition = (i * TILESIZE) ; //13 is padding from left
                int yPosition = (j * TILESIZE) ; //45 is padding from top
                mazeTiles[i, j].SetBounds(xPosition, yPosition, TILESIZE, TILESIZE);
                //make top left and right bottom corner light blue. Used for start and finish
                if ((i == 0 && j == 0) || (i == XTILES - 1 && j == YTILES - 1))
                    mazeTiles[i, j].BackColor = Color.LightBlue;
                else
                {
                    //make all other tiles white
                    mazeTiles[i, j].BackColor = Color.White;
                    //make it clickable
                    EventHandler clickEvent = new EventHandler(PictureBox_Click);
                    mazeTiles[i, j].Click += clickEvent; // += used in case other events are used

                }
                //Add to controls to form (display picture box)
               this.Controls.Add(mazeTiles[i, j]);

            } 
        }
    }
private void createNewMaze()
{
mazeTiles=新的PictureBox[XTILES,YTILES];
//获取所有瓷砖的循环
对于(int i=0;i
这就是我得到的:


我找不到解决方案,也许有人可以,提前谢谢

您显示的代码看起来很好(对我来说也很有用)。您确定正在调用此方法吗?您是否有
CreateNewMaze()Form()
构造函数中的code>line?这就是问题所在,在调试时,没有调用此方法显示你的表单构造函数,然后…啊,对不起,我没有调用该方法,谢谢你的帮助!:Ppublic Form1(){InitializeComponent();createNewMaze();}