How to write event handler in VB?
Kevin
✭✭
in RobotStudio
My VB add-in needs to detect when a new selection is made in the graphics window.
I think I have to link my subroutine to to the GraphicPicker.GraphicPick event, but cannot work out how to do this from the API Help.
Would somebody please give me some example code.
Thanks,
Kevin
I think I have to link my subroutine to to the GraphicPicker.GraphicPick event, but cannot work out how to do this from the API Help.
Would somebody please give me some example code.
Thanks,
Kevin
0
Comments
-
The following topic discusses event handling in C#. Perhaps that can give some guidance.
Henrik Berlin
ABB0 -
... btw ... It think this is the event to use
Public Event SelectionChanged As EventHandler
Henrik Berlin
ABB0 -
Thanks for your reply Henrik,
The API Help shows 'SelectionChanged' associated only with 'ToolControlBase', 'CommandBarComboBox' and 'ReferenceComboBox' but states that the 'GraphicPicker.GraphicPick' event ... "occurs when the user picks an object in a graphic view", which I think is what I want.
I have converted the C# example from your link to VB, but after much experimenting I still have not managed to write a working handler and link it to my required event.
I would be very grateful if someone would give a detailed example of how to do this in VB.
Thanks,
Kevin
0 -
OK, I sorted it. For the benefit of anyone else who is struggling with event handlers in VB, here is an example which displays a message box whenever a face or body are selected.
Add a reference to 'ABB.Robotics.RobotStudio.Stations.Forms' in the form or module properties then include this line at the start of the form/module code:
[CODE]Imports ABB.Robotics.RobotStudio.Stations.Forms[/CODE]
Add this code so that it executes before a graphic selection will be made:
[CODE]AddHandler GraphicPicker.GraphicPick, AddressOf MySub_SelectionChanged[/CODE]
Then add the handler subroutine:
[CODE] Public Sub MySub_SelectionChanged(ByVal sender As Object, ByVal e As GraphicPickEventArgs)
If e.PickedObject IsNot Nothing Then
If e.PickedObject.TypeDisplayName = "Face" Then
MsgBox("Face selected")
ElseIf e.PickedObject.TypeDisplayName = "Body" Then
MsgBox("Body selected")
End If
End If
End Sub
[/CODE]
Kevin
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings