Results 1 to 5 of 5

Thread: create a dynamic form

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2013
    Posts
    35

    Question create a dynamic form

    I wonder if it is possible to create a form at run time. I do not want to instantiate an existing class
    Please, help me

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: create a dynamic form

    yes it's possible. You do it the same way you'd create a dynamic control with the New keyword. Then use AddHandler to hook up events, add dynamic controls and handlers for those too...
    That's all there is to it.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: create a dynamic form

    Heck, if you look at the designer file you'll see that's exactly how it's done... all of the controls are created at run time, then added to the form. It's just that the IDE then takes that designer file and gives you a warm, soft GUI to work with. There's nothing to say that you can't hand-code it all yourself. But you're still instanciating a class (the form) ... so unless there's a fluid reason for doing so, there really isn't much point in it (other than an exercise in "gee this is far easier to do in the IDE").

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: create a dynamic form

    The only time i've ever created my own forms that way was when creating an app that used the CodeDomProvider class to create executables...

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: create a dynamic form

    You also don't need a designer file. Those were only introduced with the 2005 version when partial classes were added. Prior to that, all the designer code was just stuck into a region in the one and only code file for the form.
    My usual boring signature: Nothing

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