CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    65

    How can you show 2 forms at once?

    Hi,

    I have buttons and graphics on two seperate forms. However when I hit `Run` only Form 2 shows up. How can I reveal both forms and have the 2nd form placed underneath the first. Also, How can I link buttons on the 1st form, to things that happen on the 2nd?

    Thanks

    Mark


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: How can you show 2 forms at once?

    In the form_Load or Form_Activate event of the form that shows up issue a Formx.SHOW to show the second form.
    A more sophisticated way would be to add a SUB MAIN in a module, Set the startup Object in project properties to Sub MAIN.
    In sub main issue two statements like this


    public Sub Main()
    Form1.Show
    Form2.Show
    End Sub




    John G

  3. #3
    Join Date
    Jan 2001
    Posts
    165

    Re: How can you show 2 forms at once?

    Under project properties there is a setting called StartUp object. You set this to the object you want to start when you run the app. If you want Form1 to start first then set this to Form1.

    If you want to also show Form2 on startup then in the Load event of Form1 put this line:

    Form2.Show

    As far as linking objects from one form to the other use just reference them in code using the Form Name as the qualifier. Example:

    In Form1:

    private sub Command1_Click()
    Form2.Text1.Text = "Message from Form1"
    End Sub


    -K


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

Featured