|
Thread: Mdi
-
Feb 28th, 2003, 11:21 AM
#1
Thread Starter
Frenzied Member
Mdi
I'm using this code to determine if an instance of the form is already open, but I get an error...any suggestions?
Code:
Dim frmdataentry1 As frmDataEntry = Nothing
If frmdataentry1 Is Nothing Then
frmDataEntry1 = New frmDataEntry()
frmDataEntry1.MdiParent = Me
frmDataEntry1.Show()
End If
Additional information: The form that was specified to be the MdiParent for this form is not an MdiContainer.
-
Feb 28th, 2003, 11:46 AM
#2
I don't believe you can set a non MDI Container to be an MDI Parent, but you didn't mention what error you are getting. Also the way you have that code the IF is not needed as it will always be true. You set the object to nothing and then on the next line test if it is nothing or not, but since you just set it to be nothing it will always be true.
-
Feb 28th, 2003, 02:44 PM
#3
Thread Starter
Frenzied Member
I guess that explains why it's not working...Any adive on what I can do to check if a child form is already running in the parent and if it is, make it the active form?
-
Feb 28th, 2003, 03:19 PM
#4
You could loop through the MDIChildren and see if any of them are of the type you need. There might be a better way but that should work.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'find a form in the children of type form1
Dim frm As Form
For Each frm In Me.MdiChildren
If frm.GetType Is GetType(Form1) Then
frm.Activate()
End If
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|