STOP form_load
-
hi, i have to stop the load of my form when i catch an error, i want to close the form. but if i write: try { ... } catch { Close(); } i get an error. because it's impossible to close form on load. someone has any ideas? how can i stop the load? thanks a lot. Cliffer
-
hi, i have to stop the load of my form when i catch an error, i want to close the form. but if i write: try { ... } catch { Close(); } i get an error. because it's impossible to close form on load. someone has any ideas? how can i stop the load? thanks a lot. Cliffer
I don't know it if is what you really need... but try this. private void mdi_Load(object sender, System.EventArgs e) { try { throw new Exception ( "Error" ); } catch { this.Closing += new CancelEventHandler(mdi_Closing); OnClosing( new System.ComponentModel.CancelEventArgs ( false ) ); } } private void mdi_Closing(object sender, CancelEventArgs e) { System.Windows.Forms.Application.Exit (); } Hope It works Ricardo Casquete
-
hi, i have to stop the load of my form when i catch an error, i want to close the form. but if i write: try { ... } catch { Close(); } i get an error. because it's impossible to close form on load. someone has any ideas? how can i stop the load? thanks a lot. Cliffer
Hi You don't say how you are showing the form. If you are showing it using
ShowDialog
, you can just set theDialogResult
property:private void Form2_Load(object sender, System.EventArgs e)
{
try
{
...
}
catch
{
DialogResult = DialogResult.Abort;
}
}---------------------------- Be excellent to each other :) EasiReports[^] My free reporting component for WinForms.