views:

25

answers:

2

I am trying to add a bunch of controls dynamically in rows and columns in a windows form. For ex: if i have 20 controls and i need to create 3 columns and n rows. How to achieve this. Any suggestions will be appreciated. Thanks N

+1  A: 

Add a TableLayoutPanel to your form. At runtime, instantiate your controls using the new keyword. Add them to the tableLayoutPanel.Controls collection. You can either add them to specific rows and columns, or let panel have them flow into the next available cell.

Tim Robinson
A: 

I aggree with Tim.

However, If you know that you are always going to be adding the controls in sets of 3, I would reccomend creating a user control to contain the 3.

Seattle Leonard