Not exactly what I originally had in mind, but this actually works...
VB Code:
Private Sub UserControl_InitProperties() Dim DeleteMe As Boolean Dim Obj For Each Obj In UserControl.ParentControls 'TestControl I named the control I was testing this code ' change it to whatever is your control named If TypeOf Obj Is TestControl Then If Obj.hWnd <> UserControl.hWnd Then DeleteMe = True Exit For End If End If Next If DeleteMe Then MsgBox "You cannot place more than one control of this type" SendKeys "{DEL}" End If End Sub Public Function hWnd() As Long hWnd = UserControl.hWnd End Function




Reply With Quote