RobotStudio event

Change view

Options
Hello all!!!

I'm just newbies in RAB Tongue , and I want to know how to change the form when one button is pushed. (the same of a touch pannel for change the view...)

Thx

Comments

  • Hello!
     

    If the second form (that you want to launch when pressing a btn) inherits TpsForm the code to achieve this is very simple:

     


    private
    void button1_Click(object sender, EventArgs e)
    {

           _viewProd = new ViewProd();


          _viewProd.ShowMe(
    this);
    }
    If the second view inherits TpsControl, however, you need to add it to the control collection of the first form before you launch it (just like an ordinary .Net control).
    Best regards,

    Ingela Brorsson
    Software Engineer
    ABB Robotics, Sweden
  • Hello...

    Thank you for your help,

    I have try to do the same  in VB with the following lines :

     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim _view2 As view2
            Me.Hide()
            _view2 = New view2()
            _view2.Show()
            _view2 = Nothing
        End Sub


    I have created the Form view2

    but when i execute the code in the virtualflex, the form1 is good hiding but the view2 is not show.

    do you have a solution for that?

    thx


  • If your second view is a TpsForm, this is an example of how to do it:

    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Try
                Me._viewProduction = New ViewProduction(Me._controller)
                AddHandler Me._viewProduction.Closed, New EventHandler(AddressOf Me._viewClosed)
                Me._viewProduction.ShowMe(Me)
                Me._viewProduction.Activate
            Catch exception As Exception
                Me.DisplayErrorMessage(exception.Message)
            End Try
        End Sub


    Some advice:
    1. Use try - catch for ALL event handlers. There is only ONE GUI thread on the FlexPendant, if you break it the FlexPendant will crash...
    2. To save resources on the FlexPendant, use only ONE Controller object in your application, and pass it as an argument to the secondary view.
    3. Add event handler to be notified when the second view is closed. In this event handler you call the Dispose method of the second view and set it to Nothing. Make sure the Dispose method of the second view cleans up properly (eg.  objects that are holding subscriptions to controller events should release these before they are disposed of), but don't kill the Controller object that was passed to it!
    4. Launch the second view.
    5. Call a method in the second view that activates any subscriptions to controller events and updates the UI.

    Also - I really recommend you to spend some time reading all relevant sections in the User's Guide. There is quite a lot to think about when you are coding an application for a small device with limited resources, such as the FlexPendant.

    Best regards,

    Ingela Brorsson
    Software Engineer
    ABB Robotics, Sweden