Page 1 of 1

Multi Forms Passing data bidirectional

Posted: Thu Nov 28, 2024 9:55 am
by CKMHC-it
I am trying to pass data from parent to child and child to parent.
I see how to get data from text boxes
how do I pass variables, arrays, datasets...

Thank you for any help you can provide.
Chris

Re: Multi Forms Passing data bidirectional

Posted: Sat Nov 30, 2024 11:29 am
by brittneyr
You may find the following helpful:
https://info.sapien.com/index.php/guis/ ... jects-work

Re: Multi Forms Passing data bidirectional

Posted: Mon Dec 02, 2024 8:30 am
by CKMHC-it
This is on may Main form, but $MainForm_BiDerData always stays Tom in the main form even when I set it to Chris on the ChildFor
I am not sure what I am missing but it acts like a constant on the main form
  1. $MainForm_Load= {
  2.     #TODO: Initialize Form Controls here
  3.    
  4. }
  5. $button1_Click= {
  6.     #TODO: Place custom script here
  7.     $script:MainForm_BiDerData = "Tom"
  8.    
  9.         if ((Show-ChildFor_psf) -eq 'OK')
  10.     {
  11.         $textbox1.Text = $MainForm_BiDerData #This stays set to Tom even though it is set to Chris in the Childfor
  12.     }
  13. }
  14.  
  15. $ChildForm_Load={
  16.     #TODO: Initialize Form Controls here
  17.  
  18.    
  19. }
  20.  
  21. $button1_Click={
  22.     #TODO: Place custom script here
  23.     $MainForm_BiDerData
  24.     $MainForm_BiDerData = "Chris"
  25.    
  26.     $ChildForm.DialogResult = 'OK' #When I get here $MainForm_BiDerData shows Chris
  27.     $ChildForm.Hide()
  28.  
  29. }

Re: Multi Forms Passing data bidirectional

Posted: Thu Dec 05, 2024 7:59 am
by brittneyr
Since you are initially declaring the variable in the MainForm, its best to use the $script: scope when you reference/change that variable. This would mean updating the variable in the child form to the $script: scope.