2
Reply

Passing a form as an argument

ron-rohrssen

ron-rohrssen

Dec 11 2003 3:51 PM
2.2k
I want to show a dialog and when the form (dialog) is closed, return to the calling form. The calling form should then be able to pass the child form to another object with the form as a parameter. For example, FormOptions formOptions = new FormOptions(); if (formOptions.ShowDialog(this) == DialogResult.OK) { ConfigurationManager configurationManager = new ConfigurationManager(); configurationManager.saveConfiguration(formOptions); } formOptions.Dispose(); My ConfigurationManager has a method that looks like this: public void saveConfiguration(FormOptions formOptions) { ConfigurationData configurationData = new ConfigurationData (formOptions); saveConfiguration(configurationData); } When I build this code I keep getting an error like this: ConfigurationData.cs(20): The type or namespace name 'FormOptions' could not be found (are you missing a using directive or an assembly reference?) These classes are all within the same namespace. Is it possible to pass the form object to another class? Or do I need to extract values from the form and pass them on to my ConfigurationManager?

Answers (2)
Next Recommended Forum