MDI Child Variables

I have a DataSet created in a MDI child form. How can I access it from the MDI parent

DataSet DS = this.ActiveMdiChild.


Answer this question

MDI Child Variables

  • Sarit Kommineni

    However, I do not have the name of the childform. It can be anything.

    So, when I say
              DataSet DS = this.ActiveMdiChild.MyDataSet;

    It will give an error MyDataSet is not defined.


  • Abstract Labs

    One way is to create a property in the MDI like:

    public DataSet MyDataSet
    {
       get{return theDataSet;}
    }

    and then access it from the parent

    // assumes a reference to the child form is child

     DataSet childDataSet = child.MyDataSet;


    Brad Raulston

  • fujimaster4

    you could cast it

    if(ActiveMdi Child is MyForm1)
    {
       DataSet ds = ((MyForm1)activeMdiChild).MyDataSet;
    }

    Brad Raulston


  • MDI Child Variables