Results 1 to 6 of 6

Thread: how do i stop creating lots of forms

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Norwich, UK
    Posts
    405

    Unhappy how do i stop creating lots of forms

    i have a form (form1) which has a button, which when clicked opens a new form (form2).

    My problem is that after clicking form1's button to open form2, i can go back to form1 and repeatedly click the button to create multiple instances of form2.

    So my question is how do limit form1 to only create one instance of form2?

  2. #2
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    have only one instead of form 2 created do not instanciate it in the button click

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    http://abstractvb.com/code.asp?A=1096

    Take the code from that above, and apply it to your form class code. It should do the trick.

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Sorry,

    Forgot I was in the C# forum...

    Here is a C# link for you:

    http://www.c-sharpcorner.com/Code/20...tonPattern.asp

  5. #5
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Unless you don't want the user to get back to Form1 until Form2 is closed.

    In that case just do a ShowDialog()
    Code:
    Form2 frm2 = new Form2();
    
    frm2.ShowDialog();

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Probably closer to this actually

    Code:
    Form2 frm2 = new Form2();
    
    frm2.ShowDialog(Me);
    or if you want a fancy one-shot...

    Code:
    x = (new Form2).ShowDialog(Me)
    I don't live here any more.

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