Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ShowModal Form not responding
Message
De
22/05/2006 14:14:44
 
 
À
22/05/2006 11:53:29
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01123528
Message ID:
01124037
Vues:
19
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;
		// etc.etc.
		// Do any other processing
	}

	public void SetOptions()
	{
		this.opOptions.OptionOne = this.MyOptions.OptionOne;
		this.opOptions.OptionTwo = this.MyOptions.OptionTwo;
		// etc.etc.
	}
}
~~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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform