Results 1 to 9 of 9

Thread: Form in a form

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Form in a form

    I found it is very easy to put a form inside another form, which can be very handy if you want to use some forms that have duplicate parts on them, but have some differences. Visual Inheritence can be used as well, but sometimes that is not so easy to implement, and this method allows you to easily put the embedded form anywhere on the master form.

    Attached is a very basic example
    Attached Files Attached Files

  2. #2
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Re: Form in a form

    i like it!
    If you find my thread helpful, please remember to rate me

  3. #3
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Form in a form

    Quote Originally Posted by kleinma
    I found it is very easy to put a form inside another form, which can be very handy if you want to use some forms that have duplicate parts on them, but have some differences. Visual Inheritence can be used as well, but sometimes that is not so easy to implement, and this method allows you to easily put the embedded form anywhere on the master form.

    Attached is a very basic example
    Why would I want to do this?
    And for what?

    Is it really loading the form2?

    This is different!
    Cool!

  4. #4
    Fanatic Member
    Join Date
    Oct 2003
    Posts
    1,005

    Re: Form in a form

    Cool!... I set the border so the title bar shows up.

    hey kleinma,
    Can this be made into a dock window system?

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Form in a form

    well the form is technically a control (it inherits from control) so you can add a form to a container control's controls collection.

    You need to set the embedded forms TopLevel property to false, so it does not register as a top level form (this allows it to be placed in another control)

    I imagine you could use it for a dock window system

  6. #6

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Form in a form

    I have also found (through playing around) that if the form you are embedding in the master form is NOT in the same project (but in a reference, like a class library), you need to change the scope of the controls you want to expose from friend to public. If the form is in the same project (as in the example I uploaded) Friend is ok as the modifier.

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

    Re: Form in a form

    Maybe this would make a good CodeBank thread? Interesting idea.
    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

  8. #8

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Form in a form

    true. I am actually using this method in an app I am working on, so as I get a little further in, I will work out any fine details that I should include and post it there. It is pretty cool, and while it is very basic, I was really happy to see it was possible, it never was in VB6 without using a bunch of APIs that never would allow the window to act right anyway.

  9. #9
    Junior Member
    Join Date
    Mar 2004
    Posts
    22

    Re: Form in a form

    THANKS SO MUCH FOR THIS!!!


    this is actually very usefull if you want to create an application that is one big activex control and deploy it over via IE.

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