Steve,
There are at least two ways to address this --
Either will work just as well.
For this example lets say we have MainForm and PopupForm. In case 1
you may add a constructor to PopupForm (it should inherit the this()
constructor so that it will override the main constructor properly)
that accepts a reference to the MainForm and then simply reference
conrtols on the MainForm using that passed reference (of the MainForm)
-- You can also setup a reference to the PopupForm in the MainForm and
use that to extract information.
i.e.
class PopupForm
{
....
private MainForm MyParentForm; //Field to hold MainFormReference
public void PopupForm(MainForm ParentRefToMainForm):this()
{
this.MyParentForm = ParentRefToMainForm;
}
next when you call this PopupForm in the MainForm class do something
like this:
class MainForm
{
....
function PopupFormButton_OnClick()
{
PopupForm myform = new PopupForm(this);
myform.WindowState=FormWindowState.Normal;
myform.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n;
myform.ShowDialog ();
}
if (myform.DialogResult == DialogResult.OK &&
myform.SomeLabel.ToString().Trim() != "" )
{
this.MainFormLabel.Text =
myform.SomeLabelPropertyWhichReadsThePopupDataToBe PassedBackToMainForm;
}
}
Case # 2 -
Setup properties on either form and reference the field information
you want to pass using the properties (can be static or instanced
values). You should setup fields in both forms to hold the data you
need to pass.
I would suggest (if you need to pass datasets that you do so as
reference values to ensure that updates are posted to the form quickly
and without consuming too many resources.
--
Tommie Carter
tcarternyc(at)hotmail(dot)com
--
"Steve" <ho******@cmmts.com> wrote in message news:<0b****************************@phx.gbl>...
Can anyone recommend the best way to pass a string back to
the calling class (windows form) from a dialog that was
shown modally using ShowDialog?