To access variable from MDI child form
From the MDI parent form, how can I access the variable defined in the MDIchild. When I say ActiveMdiChild.xxx it says the xxx not defined.
[139 byte] By [
rkbnair] at [2007-11-11 7:25:14]

# 1 Re: To access variable from MDI child form
What data type is ActiveMdiChild? System.Windows.Forms.Form. Unless xxx is a property of the System.Windows.Forms.Form class, you must cast ActiveMdiChild to the specific type that defines the xxx property. If you need an example, please tell us which language you're using.
# 2 Re: To access variable from MDI child form
c# please.
The childform contains the following statements. I want to access the DataSet northwindDS from its parent MDI form.
namespace Microsoft.Samples.Windows.Forms.DataGridViewSample
{
partial class frm_Materials : Form
{
public DataSet northwindDS;
# 3 Re: To access variable from MDI child form
using Microsoft.Samples.Windows.Forms.DataGridViewSample;
frm_Materials activeForm = ActiveMdiChild as frm_Materials;
if (activeForm != null)
{
// use activeForm.northwindDS as needed
}
# 4 Re: To access variable from MDI child form
But, I do not know the name of my MDIChild form: it can be abc,xyz, or pqr.
So, how can I refer to it?
# 5 Re: To access variable from MDI child form
You don't need to know the name of the form, just its type. All your child forms should be of the same type (or inherit from a common base type). The name of that type (class) is all you need to know.