ahbenshaut
Well-known member
Good Day. Kinda banging my head against the wall on this one. I have a Mdi application with the start form(mdiparent) and form1(mdichild). On the start form, there is a textbox and a button. Heres how I want it to work:
1. value is entered into textbox and button is clicked
2. if form1 is open with that value, Bring it to the front
if not, create a new instance of form1
Here's the code I am using. If there is an easier way, please let me know:
1. value is entered into textbox and button is clicked
2. if form1 is open with that value, Bring it to the front
if not, create a new instance of form1
Here's the code I am using. If there is an easier way, please let me know:
VB.NET:
If Not IsNothing(frmForm) Then 'If it is something
If Not frmForm.IsDisposed Then 'it's not disposed
'loop through the open form1s and compare the form1s property to the startform textbox
'if its the same, bring the form1 to the front
For Each frmForm As Form1 In Me.MdiChildren
If frmForm.TestProperty = TextBox1.Text Then
frmForm.BringToFront()
IsLoaded = True
Else
IsLoaded = False
End If
Next
If IsLoaded = False Then
frmForm = New Form1()
frmForm.MdiParent = Me
frmForm.TestProperty = TextBox1.Text
frmForm.Show()
End If
Else
frmForm = New Form1()
frmForm.MdiParent = Me
frmForm.TestProperty = TextBox1.Text
frmForm.Show()
End If
Else
frmForm = New Form1()
frmForm.MdiParent = Me
frmForm.TestProperty = TextBox1.Text
frmForm.Show()
End If