C #: What is the correct way to show the form for "frmMainForm" settings and disposal?
4 answers
Perhaps a Dialog is a better fit for your Preferences form. There are subtle differences between dialogue and form that would make dialogue easier to handle. A return code indicating the button that was clicked makes dialog boxes useful.
Suppose you used a dialog - the using statement (from the top of the head) can be used:
using (DialogSettings dlgSettings = new DialogSettings)
{
if (dlgSettings.ShowDialog() == DialogResult.OK)
{
}
}
If you insist on using a form, you have to
- Enter the form
- show form
- record if ok or cancel was clicked to navigate to the form level variable (from form code ok / cancel button click)
- hide form
- save the recorded value from the form
- delete the form
- use saved value ok / cancel
+3
source to share
fyi, using "frm" is not a recommended part of the C # coding rules. Microsoft prefers that you don't use Hungarian notation in .NET at all .
+1
source to share