Quote:
Originally Posted by GaryTexmo
Also, since the form is being shown as a dialog, you can always expose some public properties that your main form can read when you're finished. Just remember that you can't directly read the value of a control because, as the form has closed, those controls are now disposed.
Is this true ? (that you can't access the controls once ShowDialog has returned). I often have the following:
-
void Configure(){
-
frmConfigure frmconf = new frmConfigure(Title, setting1, setting2);
-
if (frmconf.ShowDialog() == DialogResult.OK){
-
setting1 = frmconf.Setting1;
-
setting2 = frmconf.Setting2;
-
}
-
where
-
partial class frmConfigure{
-
public string Setting1 { get {return TextBox1.Text; } }
-
public string Setting2 { get {return TextBox2.Text; } }
-
}
-
My reading of the designer generated code for frmconf is that the components are only disposed when the form is disposed. Now, since I still have a reference to frmconf after ShowDialog returns, the form should not be disposed and the controls still exists.
Is this correct, or have I just been lucky that my program hasn't crashed so far ?