Results 1 to 4 of 4

Thread: How do I delete/remove custom control from a form programmatically?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    63

    Question How do I delete/remove custom control from a form programmatically?

    Hello I created a custom control and add it to a form programatically.

    The user can add and move them all over the form.

    The problem is when I want to clear the form of my user control I don't know how.

    I created an array of my control called ctlCorkNotes

    Say I create ctlCorkNotes(1) and now I want to delete it.

    How do I do this so it is gone and would have to recreate it to show up again?

    Thanks for your help.

    Mythos

  2. #2
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: How do I delete/remove custom control from a form programmatically?

    First of all, set the visible property to false and then use this method:
    ctlCorkNotes.Dispose()

    That will release all resources to your control.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do I delete/remove custom control from a form programmatically?

    Quote Originally Posted by Zeelia View Post
    First of all, set the visible property to false and then use this method:
    ctlCorkNotes.Dispose()

    That will release all resources to your control.
    The Visible property is irrelevant. Call the control's Dispose method and then Remove it from its Parent's Controls collection.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: How do I delete/remove custom control from a form programmatically?

    off-topic: I like irrelevance :P
    No, but honestly I don't know why I wrote that..

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