Why can I not use the Unload statement in a ComboBox's Click event?
Posted on 2004-04-02
I have a "preview screen" that displays a list of "options" when the user chooses an "item" from the "item list".
Each "item" will have a different number of "options" to display in the "preview screen".
Each "option" is displayed as a Label Control array control element in the "preview screen".
The "preview screen" displays the appropriate "options" the first time the user chooses an "item" from the "item list".
But, when the user chooses another "item" from the "item list", the Label Control array control elements dynamically created from the previous "item" chosen must be Unloaded so to allow the "preview screen" display a fresh list of "options".
When the application attempts to Unload a Label Control array control element (i.e., Unload lblControl(1) ), the application returns a Run-time error '365' which states "Unable to unload within this context".
Apparently the Unload statement cannot be executed from code that is called from a Combo Box's Click event.
Why?!? I am just Unloading a control and not the form.
I know I will have to use the tag property now, but this just sucks.
Why does the Run-Time Error 365 exist if I am just Unloading a control?!?!