Results 1 to 7 of 7

Thread: [RESOLVED] Remove control during runtime?

  1. #1

    Thread Starter
    Lively Member VBNubcake's Avatar
    Join Date
    Feb 2008
    Location
    Caledon, Ontario, Canada
    Posts
    80

    Resolved [RESOLVED] Remove control during runtime?

    Hey there,

    does anyone know how to remove a control during runtime? Not disable or make it invisible, i want to remove it all together, making it no longer existing.

    Example:

    What would the code be to delete a command button (named cmdButton) during runtime?

    Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Remove control during runtime?

    Unload but if the control is added to your form at designtime then you cant programmatcially unload it like you do with controls added at runtime. I may be wrong as I havent done that in years but should be correct.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Remove control during runtime?

    AFIK only objects loaded in runtime can be destroyed in runtime, whats wrong with just hiding it?
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  4. #4

  5. #5

    Thread Starter
    Lively Member VBNubcake's Avatar
    Join Date
    Feb 2008
    Location
    Caledon, Ontario, Canada
    Posts
    80

    Re: Remove control during runtime?

    thank you all

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] Remove control during runtime?

    FYI: For anyone that cares. One annoying exception to being able to unload what you load dynamically.... You cannot unload objects from within a combobox click event, or from within any routines/functions called during the process of the click event. Try it; should get an error saying you can't unload "in this context".

    If you ever get caught in that situation, use a timer, activate the timer as the last statement in the combo's click event, and on the timer's event unload the control. Just a tidbit worthy of keeping in the back of your mind so you don't go loony if it happens to you.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Lively Member VBNubcake's Avatar
    Join Date
    Feb 2008
    Location
    Caledon, Ontario, Canada
    Posts
    80

    Re: [RESOLVED] Remove control during runtime?

    lol thanks for the advice, that will probably come in handy

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