MessageBox like form

Pirahnaplant

Well-known member
Joined
Mar 29, 2009
Messages
75
Programming Experience
3-5
How can I make a Form act like a message box, where you can't return back to the main/parent form until it has been closed?
 
VB.NET:
ChildForm.ShowDialog
 
Thanks.
How can I get the Child Form to Return Windows.Forms.DialogResult.OK
VB.NET:
If ChildForm.ShowDialog() = Windows.Forms.DialogResult.OK Then
   MsgBox("Form Returned OK")
End If

Edit: Never mind, I found it: Me.DialogResult
 
Last edited:
Set the form's AcceptButton and CancelButton properties to their respective button's, then set the each button's DialoResult property to their respective values.
 
Also whenever you use the ShowDialog method, you should specificly dispose of the form when it is done.

VB.NET:
If ChildForm.ShowDialog() = Windows.Forms.DialogResult.OK Then
   MsgBox("Form Returned OK")
End If

ChildForm.Dispose
 
Back
Top