Multiple instances of the same form
Posted on 2004-11-08
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:
Public Class Form1
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"
Public Class Form2
Public TestValue As String
...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?