Multi Forms Passing data bidirectional

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.

This forum is a space to discuss coding involving Graphical User Interfaces (GUI) in PowerShell or using WinForms controls, and technical issues related to development.

- Question about a licensed SAPIEN product? Post here: Product Support for Registered Users
- Question about a trial SAPIEN product? Post here: Former and Future Customers - Questions
Post Reply
CKMHC-it
Posts: 11
Last visit: Wed Dec 11, 2024 9:59 am

Multi Forms Passing data bidirectional

Post 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
User avatar
brittneyr
Site Admin
Posts: 1824
Last visit: Thu Dec 12, 2024 8:05 am
Answers: 45
Been upvoted: 36 times

Re: Multi Forms Passing data bidirectional

Post by brittneyr »

You may find the following helpful:
https://info.sapien.com/index.php/guis/ ... jects-work
Brittney
SAPIEN Technologies, Inc.
CKMHC-it
Posts: 11
Last visit: Wed Dec 11, 2024 9:59 am

Re: Multi Forms Passing data bidirectional

Post 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. }
User avatar
brittneyr
Site Admin
Posts: 1824
Last visit: Thu Dec 12, 2024 8:05 am
Answers: 45
Been upvoted: 36 times

Re: Multi Forms Passing data bidirectional

Post 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.
Brittney
SAPIEN Technologies, Inc.
Post Reply