Adding and Deleting Controls at Run Time
See Also Example
Because control arrays in Visual Basic are dynamic, you can add or delete controls in a control array at run time However, you must first create a control array containing at least one control at design time , and then you can write code (using the Load and Unload statements) to dynamically add or delete controls from the array at run time..
To add or delete controls in a control array at run time
1. Create a control array.
If you create a control array only so you can add controls at run time, you can accomplish this by setting the Index property on a single control at design time.
2. Open the Code window by double-clicking a control in the control array.
3. Go to the event or procedure where you want to load or unload members of the control array and write the appropriate code.
Note At run time, you cannot remove controls that were created at design time.