Adding and Deleting Controls at Run Time

See AlsoprocDynamicControlArraySee                 ExampleprocDynamicControlArrayX>Low

Because control arrays in Visual Basic are dynamic, you can add or delete controls in a control array at run timeCYRM35.  However, you must first create a control array containing at least one control at design timeCFSL0V, and then you can write code (using the LoadGU0759 and Unload17FKE8Z 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. CreateBRU4A5 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 windowJ73QNY 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.