easier way to create grid than creating 900 controls c#.net
<p>I'm trying to write a program that creates a 30x30 grid of 20px x 20px boxes. When you click on a box in the grid it changes the color of the box and stores the RGB value of it and the x,y coordinates (hidden in the box). So basically I'm making a simple paint program. The purpose of it is to assist me in programming LED RGB animations for a 30x30 pixel grid. So once I draw something I export the X,Y,R,G,B of each pixel in the image. </p>

<p>So my question is, is there an easy way to do this. With out creating 900 buttons and putting them together? I've got something sorta working :</p>

<pre><code>            Panel BU = new Panel();

            BU.AutoSize = false;
            BU.Location = new System.Drawing.Point(xpos, ypos);
            BU.BackColor = System.Drawing.Color.Transparent;
            BU.Font = new System.Drawing.Font("Microsoft Sans Serif", 5, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            BU.Name = row_num + " x " + col_num;
            BU.Size = new System.Drawing.Size(20, 20);
            BU.MouseDown +=new MouseEventHandler(BU_MouseDown);
            BU.MouseEnter +=new EventHandler(BU_MouseEnter);

            this.Controls.Add(BU);

            xpos = xpos + 20;

            px_num++;
            col_num++;

            if (col_num == 30) { col_num = 0; ypos = ypos + 20; row_num++; xpos = 0; };
</code></pre>

<p>But it takes WAAAAAY to long to load.</p>
