|
-
Apr 16th, 2018, 05:09 PM
#7
Re: Prevent developer from placing a UserControl more than one time in Design Time
 Originally Posted by Simonetos The Greek
So I ended up on this...
Code:
Private Sub Me_ParentChanged(sender As Object, e As EventArgs) Handles Me.ParentChanged
If Me.ParentForm IsNot Nothing Then
Dim _UserControl = DirectCast(Me.ParentForm, Control)
If _UserControl IsNot Nothing Then
Do Until _UserControl Is Nothing
If TypeOf _UserControl Is CmosTitleBar AndAlso _UserControl IsNot Me Then
Throw New ArgumentOutOfRangeException("", "You can place only one " & _UserControl.Name & " control per form.")
End If
_UserControl = _UserControl.GetNextControl(_UserControl, True)
Loop
End If
End If
End Sub
This is incorrect : _UserControl = _UserControl.GetNextControl(_UserControl, True)
... it will only go into controls... look @ my first example...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|