Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How do I create a 3D Control Array Handler

$
0
0
Object reference not set to an instance of an object.
Error is given when trying to set Pic Location.

        PictureBox[,] Pic = new PictureBox[31, 31];

        public Form1()
        {
            InitializeComponent();
                
                for (int X = 0; X < 32; X++)
                {
                    for (int Y = 0; Y < 32; Y++)
                    {
                        Pic[X, Y].Location = new System.Drawing.Point(400 + (X * 32), 100 + (Y * 32));
                        Pic[X, Y].Size = new System.Drawing.Size(32,32);
                    }
                }
        }



The goal of the above code is to create a control array of 32 by 32 picture boxes and place them on the form to create a 32x32 grid.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>