First check whether ParentForm is null or the casting is wrong.
> I'm trying to access public properties of the parent form of a dialog
> form,
[quoted text clipped - 17 lines]
> __________________________________
> string x = ((FSDSetup)this.ParentForm).ProductDesc;
Hi Betty,
ParentForm is used for when a Control is contained within another
control. This is true if the Parent Form is an MdiContainer and you set
the Child control's MdiParent property to point to this parent.
Try something like this instead:
FSGMaint fsdgm = new FSGMaint (this);
fsdgm.ShowDialog();
And in the constructor of FSGMaint:
private FSDSetup myParent;
public FSGMaint(FSDSetup parent)
{
myParent = parent;
}
Then in the click event:
string x = myParent.ProductDesc;
====================================
Or using MdiParent:
this.IsMdiContainer = true;
FSGMaint fsdgm = new FSGMaint();
fsdgm.MdiParent = this;
fsdgm.Show();
...
string x = ((FSDSetup)this.ParentForm).ProductDesc;

Signature
Happy Coding!
Morten Wennevik [C# MVP]
Betty - 01 Feb 2005 19:29 GMT
Hi Morten,
This worked....thank you!
> Hi Betty,
>
[quoted text clipped - 31 lines]
>
> string x = ((FSDSetup)this.ParentForm).ProductDesc;
GrkEngineer - 19 Apr 2005 02:13 GMT
I'm having this same problem in C++/CLI and I understand everything you
listed, but I'm running into a problem. When I try to cast using
> string x = ((FSDSetup)this.ParentForm).ProductDesc;
I get an error because my compiler doesn't know what FSDSetup is. If I add
the header file FSDSetup.h to the FSGMaint.h, I get an error because I've
already added it to the main form and I've now created each file referencing
each other. Please help me.