.net - Correct calling of Dispose() for opened form -
.net - Correct calling of Dispose() for opened form -
let's suppose have 2 forms: forma , formb. on forma button click instance of formb created , shown.
how dispose() formb instance correctly after has been closed?
to more precise, let's suppose code creates form:
public void settings(object sender, eventargs e) { if (_settings == null) _settings = new settings(_repositorycollection, _config, this); _settings.show(); _settings.focus(); }
if want modal dialog, utilize
using (var settings = new settings(_repositorycollection, _config, this)) { settings.showdialog (); } otherwise, normal form shown @ same time forma... may not have to. see post.:
_settings = new settings(_repositorycollection, _config, this); _settings.closed += delegate {_settings.dispose ();}; .net winforms
Comments
Post a Comment