| 
 | 
								
									
										|  |  
										|  |  
										| | You can easily create ActiveX controls that work as containers for other controls, by setting their ControlContainer property to True. However, VB doesn't offer any event for detecting when the programmer adds or remove controls to the ActiveX control, after placing it on a form's surface. 
 It's pretty easy to detect such actions with the aid of a Timer control, though. Just place a Timer control on the UserControl's surface, set its Interval property to a suitable value (for example, 500 milliseconds) and then add the following code:
 | 
 | If you're working under VB6 you can add the Timer control dynamically, so it's just a matter of copying-and-pasting the following code: | 
 |  Click here to copy the following block |  | Dim WithEvents tmrNotifier As Timer 
 Private Sub UserControl_Initialize()
 
 Set tmrNotifier = Controls.Add("VB.Timer", "tmrNotifier")
 tmrNotifier.Interval = 500
 End Sub
 
 Private Sub tmrNotifier_Timer()
 Static ctrlCount As Integer
 
 If ctrlCount <> ContainedControls.Count Then
 ctrlCount = ContainedControls.Count
 
 
 
 
 
 End If
 End Sub
 | 
 |  
										|  |  
										|  |  
 
	
		| Submitted By :
					Nayan Patel 
					 (Member Since : 5/26/2004 12:23:06 PM) |  
		|  |  
		| 
				 | Job Description :   
			He is the moderator of this site and  currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |  
		| View all (893) submissions by this author 
			(Birth Date : 7/14/1981 ) |  |  |