I need to close a child form when a button is clicked on another child form.
I'm using:
pcms.frmDataEntry1.Close() - on the click event but get an error
Object reference not set to an instance of an object.
Printable View
I need to close a child form when a button is clicked on another child form.
I'm using:
pcms.frmDataEntry1.Close() - on the click event but get an error
Object reference not set to an instance of an object.
Just use a loop:
Dim frmMain as Form=Me.MdiParent
Dim frm as Form
If frmMain.MdiCHildren.Length > 0 then
For Each frm in frmMain.MdiChildren
If frm.text="Data Form" then
frm.close()
End IF
Next
End If
thanks.
another question...how can I call a procedure in different child form?
Try this example I posted here . It's not MDI but the concept you'll apply is the same I beleive plus you need to reference the parent form to the current form you're working on . http://www.vbforums.com/showthread.p...hreadid=275354
hey pirate, I was unable to open your example.
It's winrar file (you need winrar to unpack it) and the project is VB.NET 2003 . What's the problem ?Quote:
Originally posted by EyeTalion
hey pirate, I was unable to open your example.
still trying to call a procedure from one child form to another in a mdi
Private sub btnOpen ..... Handles btnOpen.Click
Dim frmMain as Form=Me.MdiParent
Dim frm as Form
If frmMain.MdiCHildren.Length > 0 then
For Each frm in frmMain.MdiChildren
If frm.text="Data Form" then
Dim frmData as frmData = frm ' the form with the function on it
Exit For
End IF
Next
End If
frmData.yourfunctionname(sender,e) ' call your function
End Sub
Haven't tried it but it should work!