Calling Method?

How do you call a method in View1 from a method in View2?

Create a property on View2 as an iosView.

When switching to View2:

dim v2 as new View2 v2.previousView = self // previousView is property we created to hold reference to view that pushed pushTo(v2)

Call method in View1 from method in View2:

View1(previousView).methodName(param) // since previousView is generic iosView, cast it as View1 class.

And to avoid the casting, create the property on View2 with the type of View1:

PreviousView As View1

Then when displaying View2:

Dim v As New View2 v.PreviousView = Self Self.PushTo(v)

Now on View2, you can just use the PreviousView property to access it public properties and methods:

PreviousView.MyPublicMethod

This strategy is less flexible, but also a bit easier to work with.

Thanks guys.

Could not get it to work. Look as if got in loop with the view open event.

What is your code? Where did you put the code?

Here is a link to the source: https://dl.dropboxusercontent.com/u/8969529/RVCLBios.xojo_binary_project

Do a find on “PreviousView”

Well, you have an infinite loop. This code in vw_Service.LoadServiceNames creates a new instance of itself and displays it:

Dim v as new vw_Service v.PreviousView = Self Self.PushTo(v)

And the Open event handler calls LoadServiceNames.

I’m afraid it’s not clear to me what you are trying to do.

The app displays info from a database. The main view, vw_veh (Vehicle view) shows all vehicle in data base (I’ve add a few more for testing) in the table, and info on the vehicle select in the table. The vw_service(Service view) shows the vehicle selected in vw_veh.

So it sounds like vw_veh ought to be displaying vw_service when something is selected. Why do you have vw_service trying to display another vw_service? And why would you need to even be calling a method on another view?

I’d work on getting the view opening/closing working first.

In the table Action event on vw_Veh, you’d do something like this to open the service view:

Dim v As New vw_Service Self.PushTo(v)

It doesn’t sound like the service view needs to do any opening of other views.

I don’t know. That the way I though that was the way you do it.