Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15908

VS 2019 [RESOLVED] Prevent ToolBox Items to drop on a control of the same class

$
0
0
[visual Basic, 2019]
Hello all.
I'm new to this forum, so smack me, if I do something stupid.

I have made a control, that I don't want to be a parent to other controls of its own class.
I know how to do this at runtime, but not how to achieve this during designTime.
By adding a ParentDesigner with the Function CanbeParentedto(), I can stop controls being dragged on my control from the form.
Code:

  Public Overrides Function CanbeParentedto(ByVal parentDesigner As IDesigner) As Boolean
        If (TypeOf parentDesigner.Component Is MainFrame) Then
            Return False
        ElseIf (TypeOf parentDesigner.Component Is Frame) Then
            Return False
        End If
        Return True
    End Function

(a forbid-icon appears, and the dragged control is not added to my control)
But controls dropped from the Toolbox, are still being parented.
How can I prevent this?
Thank in advance for any suggestions...

Quote Reply
Report Bookmark

Viewing all articles
Browse latest Browse all 15908

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>