#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Sharing data between MDI Child forms


    I would like to build an array of strings on a MDI Child form with the data contained in a StringGrid on a seperate MDI Child form.

    The code that I am using to fill the array is as follows:

    Var
    i : Integer;
    begin
    SetLength(ChartArray,60,60);
    for i := 1 to 60 do
    begin
    if frmViewFormulation.FormulaGrid.Cells[1,i] <> '' then
    begin
    ChartArray[1,i-1] := frmViewFormulation.FormulaGrid.Cells[1,i];
    end;
    end;
    end;

    This generates an Access Violation error.

    Any assistance would be appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    355
    Rep Power
    7
    Your request to have one MDI Child exchange information with another MDI Child does have significant risks associated with it, as witnessed by your Access Violation.

    Just some of the issues include:

    Do each of the two different MDI Child forms exist?
    Obviously, if one of the forms doesn't then your attempt to access that form will fail.

    Do multiple copies of any of the MDI Child forms exist?
    In an MDI Application, it's possible to have multiple copies of the same form. Which one of the multiple form instances should respond to an exchange of data?

    You have to make sure that both forms exist (are created) and that you limit the number of each form to just one instance (also possible).

    Even with these limitations, I am not sure that direct MDI Child to MDI Child is possible (I haven't tried it).
    Last edited by majlumbo; September 7th, 2012 at 01:38 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    In addition to all the caveats from majlumbo I would strongly recommend that you build
    your array in the form that contains the grid and then request it from your current form.

    Clive

IMN logo majestic logo threadwatch logo seochat tools logo