Hi
I have tried a number of ways to pass values from one view to another. One method that seems to have promise was to have a global dictionary as suggested by Michel, but I couldn’t get it to work.
I managed to get it working by putting code into the Activate method of the window I wanted to pass data into from the calling window.
I would appreciate advice as to how to do this in an optimal way.
Testers
No need to shadow all properties. There is another way that allows to keep views around and access their properties at any time from wherever :
- Create a global dictionary in a module. I called it Dico
- In app, put
Dico = New Dictionary
- In View 1 Deactivate, so the view is saved before pushing another one :
dico.Value(“View1”) = self
I added a label to View1
I then added a button to pushto a View 2 that contains two buttons :
Sub Action() View1(Dico.Value(“View1”)).Label1.Text = “Pickaboo” End Sub
Sub Action() self.close End Sub
So one button modifies the content of Label1.Text on View1 from View2, the second one closes View2.
When View1 reappears, the label has been modified.
Note that with this technique you no longer need to create a new view when you want to display again a view that already exists. For instance :
if Dico.HasKey(“View2”) then PushTo(View2(Dico.Value(“View2”))) else Dim newView As New View2 Self.PushTo(newView) end if