Set selection mode from VB
Options
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.4K RobotStudio
- 384 UpFeed
- 14 Tutorials
- 12 RobotApps
- 291 PowerPacs
- 406 RobotStudio S4
- 1.8K Developer Tools
- 247 ScreenMaker
- 2.7K Robot Controller
- 279 IRC5
- 46 OmniCore
- 6 RCS (Realistic Controller Simulation)
- 3 RobotStudio AR Viewer
- 736 RAPID Programming
- 15 Wizard Easy Programming
- 105 Collaborative Robots
- 3 Job listings