RobotStudio event

Set selection mode from VB

Options
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

Comments

  • Kevin
    Options
    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