And this is probably the best way learn- by just doing it!
To answer your question, this line:
Code:
public System.Windows.Forms.GroupBox [] gBox = new System.Windows.Forms.GroupBox[9];
creates 9 REFERENCES to GroupBox objects, but it doesn't actually create the OBJECTS themselves yet. So what you have is essentially:
Code:
gBox[0]=null
gBox[1]=null
gBox[2]=null
...
Thus the line
Code:
this.Controls.Add(gBox[GuiItem]);
Works fine because the "Add" cann accept null as a value.
However, this line
Code:
gBox[GuiItem].Size = new System.Drawing.Size(256, 72);
fails because you are trying to reference an attribute ("size") of an object that hasn't been created yet.
To fix the problem, you'll have to create 9 boxes with the "new" constructor:
Code:
gBox[0] = new System.Windows.Forms.GroupBox();
gBox[1] = new System.Windows.Forms.GroupBox();
...
Now, I didn't actually compile this (don't have c# available at the moment), so the constructor may actually requires some variables, but you get the idea.
I should also mention that you can use your loop to create each of the objects rather than doing them the way I illustrated above. I was just trying to point out the concept..
In short, when you create a variable with [] after the type, it creates an array of that type, but doesn't actually create any objects. You have to create them individually.