Change view
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, Sweden0 -
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
0 -
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, Sweden0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings