Unloading of controls

I have created one combobox.Then i added 10 , ten digit numbers.After selecting one of these numbers ,in click event of this combo box i am calling one function named Display_Operations.
In this function i am retrieving the data for corresponding selected number( from combo box).Database is SQL server.
In data base there is data for every ten digit number added to combobx.
During design time i have created one label by selecting it from tool box and dropped on to the FOM.

 Now suppose there are 20 operations ( data ) for selected ten digit number.
So in function which i am calling in click event of combobox creates the array of controls i.e. i am using Load
statement.After doing this i have created 20 labels ( array of labels) and data which nothing but operation names , i am showing on caption of these labels.

Now my question is -- When i change the
number on combo box by clicking it,
I want first unload the controls ( array of labels ) created for earlier ten digit number , and then reload the controls and display the operation name
for newly selected number.

But it doesn't allow me to unload the controls on any combo box event.As we all know that any control can not be unloaded in any combobox event.

This is the customer requirement that if i change the number it should show me the operation names corresponding to that number.

What is the solution..?

cvjoshiAsked:
Who is Participating?
 
James_stillmanConnect With a Mentor Commented:
What you can do is place a timer onto the form and place your unload controls method into a seperate sub.

do as follows:

Private Sub Combo1_Change()
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
   'call unload subroutine
   timer1.enabled = false
End Sub
0
 
crazymanCommented:
If your only displaying data for one set of operations at a time then why cant you just change the label captions instead of unloading and reloading ..just use the same labels and change appropriate properties.
0
 
James_stillmanCommented:
Sorry about the rushed description But I think  you should understand what I mean.

If you set the timer1.interval property to 1 the timer event will occur 1ms after you enable the timer so it is not causing a daley.

So place timer onto the form.

Write a sub eg. unloadControls

when the combo box event occurrs that you want to unload the controls in enable the timer.

From the timer event unload the controls or perform any other code as is desirred and then set the timer enabled property to false again

Cheers

James

0
 
cvjoshiAuthor Commented:
Adjusted points to 80
0
 
cvjoshiAuthor Commented:

 Hi, James

 I have modified code. Now it works fine.

 Regards

 Chintamani
0
All Courses

From novice to tech pro — start learning today.