Results 1 to 12 of 12

Thread: [RESOLVED] Prevent developer from placing a UserControl more than one time in Design Time

Threaded View

  1. #4
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Prevent developer from placing a UserControl more than one time in Design Time

    I don't know of a way to cancel the control creation
    Haven't got an ide in front of me to check but you could presumably just remove it:-
    Code:
    f.Controls.Remove(Me)
    By the way, I think there's a typo in your code:-
    Code:
    Dim c = f
    Should be:-
    Code:
    Dim c = f.GetNextControl(c, True)
    Unless you actually want to check the control isn't the form for some reason


    edit> crossed over

    You may or may not want this:-
    If Me.DesignMode
    While that's in they could add a second control to the form at run time.

    is the same thing?
    Not quite. The "On" methods fire the events and are the intended method for firing the event from code, rather than calling the handling event directly. The correct way to wire up an event handler is the first one.
    Last edited by FunkyDexter; Apr 16th, 2018 at 09:55 AM.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

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
  •  



Click Here to Expand Forum to Full Width