Skip to content

Options form

Victor Baleishis

Asked Mar 14, 2006, 8:19 AM EST2 answers
Share
LinkedInX

Hi!
Can anyone tell me how can I make option dialog form. Like save file dialog. I have main form and another form with some checkbokses, numeric Up-Down controls and so on. Question is how can I get information from options form to main then I close it with button "OK"?
Thanks!

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    The best way to maintain the data in the form is to move the data from the controls into properties in your form.   It's also best to bind these properties to the control so that changes to the control get moved into the properties (or visa versa).  Then after you click OK, the dialog instance will maintain the value of the control in the property.

    e.g.

    public partial class Options : Form

    {

    public Options()

    {

    InitializeComponent();

    chkOption1.DataBindings.Add("Checked", this, "Option1");

    }

     

    private bool _option1 = false;

    public bool Option1

    {

    get

    {

    return _option1;

    }

    set

    {

    _option1 = value;

    }

    }

    private void btnOK_Click(object sender, EventArgs e)

    {

    MessageBox.Show(String.Format("Checked = {0}", Option1));

    }

    }

    -Mike G.

    0
  • 0
    Thanks, but I mean other... How can a form return something?
    I from frmMain run frmOptions, then make some corrections in frmOptions, for example, change the color of frmMain. And then I press btnOK in frmOptions, it closes and frmMain is changing color, defined in frmOptions...
    0