Multiple instances of the same form

Posted on 2004-11-08
Last Modified: 2010-04-23
I have a windows form that does lots of stuff. :)  It takes a connection string for its database.  I'd like to have multiples of these forms open.  Like multiple open clients, one per window.  I would need to somehow identify each window or instance.  How would I do that?  I thought this might work:

' Form1
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim Forms(2) As System.Windows.Forms.Form ' A forms array

    ' Create 2 forms
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Forms(0) = New Form2
        Forms(1) = New Form2

        'Forms(0).Testvalue = "Form 0" ' Doesn't work
        'Forms(1).Testvalue = "Form 1"
    End Sub
End Class

' Form2
Public Class Form2
    Inherits System.Windows.Forms.Form
    Public TestValue As String
End Class

...but "Forms(0).Testvalue" is invalid.  I don't get why, it's a public variable.  So I put a textbox on form2.  "Textbox1" isn't a property of a "New Form2".

What's the best method of doing this?
Question by:MIKEV
    LVL 85

    Accepted Solution


        Dim Forms(2) As System.Windows.Forms.Form


        Dim Forms(2) As Form2


    Author Comment

    Very cool, immense thanks. :)

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now