Hey Bill,
Many times the examples that they show in Help are either not very "real world" or are too simplistic to be of much use. If one can get the general concept of something from the example, then sometimes that's enough to further expand on the sample code (not always though).
Since opOptions *is* an object and is therefore a reference type, here's how I would have handled it ... instead of setting this.opOptions once the .ShowDialog() is OK, I would call a public method on the dialog form that set the options. Something like this:
/**************************************************************/
private void optOptions_Click(object sender, System.EventArgs e)
/**************************************************************/
{
Options frmOptions = new Options(this.opOptions);
if (frmOptions.ShowDialog(this) == DialogResult.OK)
{
frmOptions.SetOptions();
}
frmOptions.Dispose();
}
And the Options Dialog form would be something like this:
public class Options : Form
{
private MyOptionsClass MyOptions;
private MyOptionsClass opOptions;
public Options(MyOptionClass PassedOptions)
{
this.MyOptions = new MyOptionsClass();
this.opOptions = PassedOptions;
this.GetOptions();
}
private void GetOptions()
{
this.MyOptions.OptionOne = this.opOptions.OptionOne;
this.MyOptions.OptionTwo = this.opOptions.OptionTwo;
}
public void SetOptions()
{
this.opOptions.OptionOne = this.MyOptions.OptionOne;
this.opOptions.OptionTwo = this.MyOptions.OptionTwo;
}
}
~~Bonnie
>Ok, when i get some time I will probably do some experimenting with this to determine the exact cause so it can be avoided in the future. I did not realize that the "this" reference in the ShowDialog() method is the default so is not needed. I will change these calls appropriately.
>
>opOptions is an instantiated object holding the options parameters. The idea was to pass the object in, perform any modifications and update the "master" object. I also suspect this is where the issue lies and I will experiment with this when I get a chance. The basic methodology was taken from an example in the Help so I will revisit this ans examine it. Thanks again for the input.
>
>Bill