joe_pool_is
Contributor
There are two methods I can use to end my program: "End" and "Me.Close()".
Is one better than the other for terminating the application?
Is one better than the other for terminating the application?
Not positive that I understand you correctly, but Me.Close should dispose the form. After calling either of the two it won't be in a usable state, i.e. you can't pull it back up and check the state of controls. I think you may have been re-creating the form without realizing it...robplatt said:ran me.close on a subform while i had checkboxes checked, i pulled the form back up and the checkboxes were still checked (it remembered their state)... calling me.dispose forgot the state and the next time i pulled the form up from within my app the checkboxes werent checked.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
Me.Show()
End Sub
No, not directly, but you need to dig a little deeper. Calling the Form.Close method causes the form to send a close message (WM_CLOSE, 0x10), which is in turn handled in WndProc, which sends the message to the WmClose function, where you can find the following [decompiled] codePlausiblyDamp said:If you use ildasm on the system.windows.forms.dll and look at the form class then you can see Close doesn't call dispose.
// ...
if ((m.Msg != 0x11) && !args1.Cancel) {
if (this.IsMdiContainer) {
foreach (Form form2 in this.MdiChildren) {
if (form2.IsHandleCreated) {
form2.OnClosed(EventArgs.Empty);
}
}
}
this.OnClosed(EventArgs.Empty);
base.Dispose();
}
void Button_Click(whatever parameters)
{
// declare a new instance of the form:
Form2^ objForm = new Form2();
objForm->ShowModal();
// execution will return here after the Modal form has closed
// so collect whatever info you need.
}
Dim frmDBClear1 = New frmDBClear()
frmDBClear1.CheckBox1.Checked = True
frmDBClear1.ShowDialog()
frmDBClear.CheckBox1.Checked = true