Results 1 to 3 of 3

Thread: [RESOLVED] opening forms

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2009
    Posts
    73

    Resolved [RESOLVED] opening forms

    Example:

    I have a main form: frmMain

    and other secundary forms: frm1 and frm2

    Main form has 2 buttons

    BUTTON1: Open form1

    dim f as new frm1
    f.tag="pepe"
    f.showdialog
    BUTTON2: Open new instance:

    dim f as new frm1
    f.tag="manolo"
    f.showdialog
    Ok. 2 instances of frm1 are opened.

    But now if the user clicks BUTTON1 will create a new instance. But I dont want this. How I can show (focus) the frm1 with tag "pepe".

    Only I want create new instances if tag is different. If tag is the same, the form will be focused.

    any idea?

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: opening forms

    You can loop through the OpenForms of the application:


    Code:
            Dim found As Boolean = False
            For Each f As Form In Application.OpenForms()
                If f.Tag.ToString() = "pepe" Then
                    f.Focus()
                    found = True
                End If
            Next
            If found = False Then
                Dim f As New Form1
                f.Tag = "pepe"
                f.ShowDialog()
            End If

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2009
    Posts
    73

    Re: opening forms



    Runs fine!

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