Background: For the most part, I'm self taught in C#, so I apologize if this is some simple-minded problem. I am creating something to the effect of a mailing list (each object has name, address, contact info, etc) and will be printing out in labels (there will be two colums and four rows per printed page). I have the list in formMain where you can add, edit and delete individual labels and I have a form printPreview(one) for individual entries selected from the list.
The problem: I'm trying to create a print preview form for the whole list; generating a group box (containing a text box and picture box) for each object from the list - that way I'll have exactly the number of labels as objects - then fill each box with the content respective to each object on the list. Each group box, text box and picture box are specific sizes and will be spaced so there's room between each label. So here's the pseudo code I'm trying to make happen;
//box[num] contains
//text box at location(6,19)
//picture box at location(222,19)
int locX = 0;
int locY = 0;
listObj = list.first;
for (int i = 0; i < list.count; i++)
{
//create box[i] at location (locX, locY);
box[i].textbox.text = listObj.text;
box[i].picturebox.image = Image.FromFile(listObj.photoLocation);
if(i%2)
{
locX+=400;
}
else
{
locY+=248;
locX=0;
}
listObj = listObj.next;
}
Now, I know there's a lot of holes in there, but I just need the basic: how do I get my program to create new group boxes in a form equal to the number of objects in my list?