September 7th, 2012, 04:13 AM
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:
i : Integer;
for i := 1 to 60 do
if frmViewFormulation.FormulaGrid.Cells[1,i] <> '' then
ChartArray[1,i-1] := frmViewFormulation.FormulaGrid.Cells[1,i];
This generates an Access Violation error.
Any assistance would be appreciated.
September 7th, 2012, 02:28 PM
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 02:38 PM.
September 7th, 2012, 05:36 PM
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.