Set selection mode from VB
Kevin
✭✭
in RobotStudio
The C# construct to set the selection mode to 'Surface' is:
[CODE]SetSelectionMode(SelectionModes.Surface);[/CODE]
I am trying to achieve the same result in VB.net under Visual Studio, but have been unable to discover the correct syntax.
My project has references to 'System.Drawing' and 'System.Windows.Forms' and includes the lines:
[CODE]Imports System.Drawing
Imports System.Windows.Forms[/CODE]
Thanks,
Kevin
[CODE]SetSelectionMode(SelectionModes.Surface);[/CODE]
I am trying to achieve the same result in VB.net under Visual Studio, but have been unable to discover the correct syntax.
My project has references to 'System.Drawing' and 'System.Windows.Forms' and includes the lines:
[CODE]Imports System.Drawing
Imports System.Windows.Forms[/CODE]
Thanks,
Kevin
0
Comments
-
The problem was due to an error in my conversion of SetSelectionMode from C# to VB.net.
Here is the working VB.net code converted from the C# example in the API help:
[CODE] ' This method sets the selection level.
Private Shared Sub SetSelectionMode(ByVal mode As SelectionModes)
' Go through all present windows.
For Each w As Window In UIEnvironment.Windows
' If there is a DocumentWindow that contains a GraphicControl
If (TypeOf w Is DocumentWindow) AndAlso (TypeOf w.Control Is GraphicControl) Then
' Set the SelectionMode.
Dim gc As GraphicControl = TryCast(w.Control, GraphicControl)
If gc IsNot Nothing Then
gc.Picker.SelectionMode = mode
End If
End If
Next
End Sub[/CODE]
This sub is called using the same construct as in C#:
[CODE]SetSelectionMode(SelectionModes.Surface)[/CODE]
This free on-line code converter did a better conversion than I managed:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
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