QuickOPC User's Guide and Reference
UABrowseDialog Class
Members  Example 



OpcLabs.EasyOpcForms Assembly > OpcLabs.EasyOpc.UA.Forms.Browsing Namespace : UABrowseDialog Class
Displays a dialog with various OPC-UA nodes (elements) from which the user can select. This dialog can be configured to serve many different purposes.
Object Model
UABrowseDialog ClassEasyUAClientSelector ClassUABrowseInputs ClassUABrowseInputsOutputs ClassUABrowseMode ClassUABrowseOutputs Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UABrowseDialog)>
<ComVisibleAttribute(True)>
<GuidAttribute("D5E91058-41DF-40D9-8DCC-795F166D0311")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<DesignerCategoryAttribute("Component")>
<SerializableAttribute()>
Public NotInheritable Class UABrowseDialog 
   Inherits OpcLabs.BaseLib.Forms.Browsing.Generalized.BrowseDialog
   Implements OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UABrowseDialog, System.ComponentModel.IComponent, System.ComponentModel.ISupportInitialize, System.IDisposable 
'Usage
 
Dim instance As UABrowseDialog
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UABrowseDialog)]
[ComVisible(true)]
[Guid("D5E91058-41DF-40D9-8DCC-795F166D0311")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[DesignerCategory("Component")]
[Serializable()]
public sealed class UABrowseDialog : OpcLabs.BaseLib.Forms.Browsing.Generalized.BrowseDialog, OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UABrowseDialog, System.ComponentModel.IComponent, System.ComponentModel.ISupportInitialize, System.IDisposable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UABrowseDialog)]
[ComVisible(true)]
[Guid("D5E91058-41DF-40D9-8DCC-795F166D0311")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[DesignerCategory("Component")]
[Serializable()]
public ref class UABrowseDialog sealed : public OpcLabs.BaseLib.Forms.Browsing.Generalized.BrowseDialog, OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes._UABrowseDialog, System.ComponentModel.IComponent, System.ComponentModel.ISupportInitialize, System.IDisposable  
Remarks

This is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has made a selection. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur.

 

General

Icon:

With UABrowseDialog, your application can integrate a dialog with various OPC-UA elements from which the user can select. This dialog can be configured to serve many different purposes.

Here is an example of the generic OPC-UA browsing dialog in action:

The way the dialog operates is controlled by two main properties:

Values of these properties can be selected from the UAElementType enumeration, which has members for various types of elements that you encounter when working with OPC-UA.

The following chart shows a hierarchy of element types that you can choose from:

For example, let’ say that you set Mode.AnchorElementType to Endpoint, and Mode.SelectElementType to Attribute. This will cause the dialog to allow the user to browse for an OPC-UA Node on a given server, and then for an OPC-UA attribute on that node.

In this case, before you run the dialog, you need to provide it with values for the InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor property, because those define your “anchor” element (Endpoint) that the user cannot change. The dialog will only allow the user to finalize it (besides cancelling) after an OPC-UA attribute is fully selected, because that is your Mode.SelectElementType. After the dialog is successfully finalized, the information about the user’s choice will be available in the Outputs.CurrentNodeElement.NodeElement and InputsOutputs.CurrentNodeDescriptor.AttributeId properties.

Note that in addition to the “minimal” scenario described above, you can also pre-set the initial node or attribute, using the InputsOutputs.CurrentNodeDescriptor.NodeDescriptor or InputsOutputs.CurrentNodeDescriptor.AttributeId properties, and after the selection is made, these properties will be updated to the new selection as well. This way, if you run the dialog again with the same value, the initial selection will be where the user has left it the last time the dialog was run.

Obviously, the chosen Mode.SelectElementType must be a child or indirect ancestor of chosen Mode.AnchorElementType in the hierarchy.

.NET

// This example shows how to let the user browse for an OPC-UA node.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UABrowseDialog
{
    static partial class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var browseDialog = new UABrowseDialog();
            browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com";
            browseDialog.Mode.AnchorElementType = UAElementType.Host;

            DialogResult dialogResult = browseDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, browseDialog.Outputs.CurrentNodeElement.NodeElement.ToString());
        }
    }
}
# This example shows how to let the user browse for an OPC-UA node.

using namespace OpcLabs.EasyOpc.UA.Forms.Browsing

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

# Instantiate the dialog object.
$browseDialog = New-Object UABrowseDialog
$browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
$browseDialog.Mode.AnchorElementType = [UAElementType]::Host

$dialogResult = $browseDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
Write-Host $browseDialog.Outputs.CurrentNodeElement.NodeElement
# This example shows how to let the user browse for an OPC-UA node.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


browseDialog = UABrowseDialog()
browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = 'opcua.demo-this.com'
browseDialog.Mode.AnchorElementType = UAElementType.Host

dialogResult = browseDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print(browseDialog.Outputs.CurrentNodeElement.NodeElement)

print('Finished.')

COM

// This example shows how to let the user browse for an OPC-UA node.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UABrowseDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UABrowseDialogPtr BrowseDialogPtr(__uuidof(UABrowseDialog));

            //
            BrowseDialogPtr->InputsOutputs->CurrentNodeDescriptor->EndpointDescriptor->Host = L"opcua.demo-this.com";
            BrowseDialogPtr->Mode->AnchorElementType = UAElementType_Host;

            // 
            DialogResult dialogResult = BrowseDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(BrowseDialogPtr->Outputs->CurrentNodeElement->NodeElement->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for an OPC-UA node.

class procedure ShowDialog.Main;
var
  BrowseDialog: UABrowseDialog;
begin
  // Instantiate the dialog object
  BrowseDialog := CoUABrowseDialog.Create;
  BrowseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host := 'opcua.demo-this.com';
  BrowseDialog.Mode.AnchorElementType := UAElementType_Host;

  BrowseDialog.ShowDialog(nil);
  // IMPROVE: check the dialog result

  // Display results
  WriteLn(BrowseDialog.Outputs.CurrentNodeElement.NodeElement.ToString);
end;
// This example shows how to let the user browse for an OPC-UA node.

class procedure ShowDialog.Main;
var
  BrowseDialog: OpcLabs_EasyOpcForms_TLB._UABrowseDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
begin
  // Instantiate the dialog object
  BrowseDialog := CoUABrowseDialog.Create;
  BrowseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host := 'opcua.demo-this.com';
  BrowseDialog.Mode.AnchorElementType := UAElementType_Host;

  DialogResult := BrowseDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  WriteLn(BrowseDialog.Outputs.CurrentNodeElement.NodeElement.ToString);
end;
// This example shows how to let the user browse for an OPC-UA node.

$UAElementType_Host = 1;

$BrowseDialog = new COM("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog");
$BrowseDialog->InputsOutputs->CurrentNodeDescriptor->EndpointDescriptor->Host = "opcua.demo-this.com";
$BrowseDialog->Mode->AnchorElementType = $UAElementType_Host;

printf("%d\n", $BrowseDialog->ShowDialog);

// Display results
printf("%s\n", $BrowseDialog->Outputs->CurrentNodeElement->NodeElement);
# This example shows how to let the user browse for an OPC-UA node.

# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
import win32com.client

UAElementType_Host = 1

browseDialog = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.Forms.Browsing.Specialized.UABrowseDialog') 
browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
browseDialog.Mode.AnchorElementType = UAElementType_Host

print(browseDialog.ShowDialog())

# Display results
print(browseDialog.Outputs.CurrentNodeElement.NodeElement)
Rem This example shows how to let the user browse for an OPC-UA node.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim BrowseDialog As New UABrowseDialog
    BrowseDialog.InputsOutputs.CurrentNodeDescriptor.endpointDescriptor.Host = "opcua.demo-this.com"
    
    Dim DialogResult
    DialogResult = BrowseDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & BrowseDialog.outputs.CurrentNodeElement.NodeElement & vbCrLf
End Sub
Rem This example shows how to let the user browse for an OPC-UA node.

Option Explicit

Const DialogResult_OK = 1

Const UAElementType_Host = 1

Dim BrowseDialog: Set BrowseDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
BrowseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
BrowseDialog.Mode.AnchorElementType = UAElementType_Host

Dim dialogResult: dialogResult = BrowseDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo BrowseDialog.Outputs.CurrentNodeElement.NodeElement

 

Multi-selection

It is also possible to configure the dialog for a multi-selection. In this mode, the user can select zero, one, or more nodes. In order to enable the multi-select mode, set the Mode.MultiSelect property to true. In the multi-select mode, the initial set of the selected nodes (when the dialog is first displayed to the user) is given by the contents of the InputOutputs.SelectionDescriptors collection. When the user makes the selection and accepts it by closing the dialog, this collection is updated, and also, all information about the selected nodes is placed to the Outputs.SelectionElements collection.

.NET

// This example shows how to let the user browse for multiple OPC-UA nodes.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UABrowseDialog
{
    static partial class ShowDialog
    {
        public static void MultiSelect(IWin32Window owner)
        {
            var browseDialog = new UABrowseDialog();
            browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com";
            browseDialog.Mode.AnchorElementType = UAElementType.Host;
            browseDialog.Mode.MultiSelect = true;

            DialogResult dialogResult = browseDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            UABrowseNodeElementCollection selectionElements = browseDialog.Outputs.SelectionElements;
            string text = "";
            for (int i = 0; i < selectionElements.Count; i++)
            {
                UABrowseNodeElement selectionElement = selectionElements[i];
                text += $"SelectionElements({i}): {selectionElement.NodeElement}\r\n";
            }
            MessageBox.Show(owner, text);
        }
    }
}
# This example shows how to let the user browse for an OPC-UA node.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


browseDialog = UABrowseDialog()
browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = 'opcua.demo-this.com'
browseDialog.Mode.AnchorElementType = UAElementType.Host

dialogResult = browseDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print(browseDialog.Outputs.CurrentNodeElement.NodeElement)

print('Finished.')

COM

Rem This example shows how to let the user browse for multiple OPC-UA nodes.

Option Explicit

Const DialogResult_OK = 1

Const UAElementType_Host = 1

Dim BrowseDialog: Set BrowseDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
BrowseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
BrowseDialog.Mode.AnchorElementType = UAElementType_Host
BrowseDialog.Mode.MultiSelect = True


Dim dialogResult: dialogResult = BrowseDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
Dim SelectionElements: Set SelectionElements = BrowseDialog.Outputs.SelectionElements
Dim i: For i = 0 To SelectionElements.Count - 1
    Dim Element: Set Element = SelectionElements(i)
    WScript.Echo "SelectionElements(" & i & "): " & Element.NodeElement
Next

 

Output reuse

The output of one dialog invocation can be used as input to a subsequent dialog invocation.

Rem This example shows use the output data (node) from one dialog invocation as input data in a subsequent dialog 
Rem invocation.

Option Explicit

Const DialogResult_OK = 1

' Define the starting node for the first dialog.

Dim BrowseNodeDescriptor0: Set BrowseNodeDescriptor0 = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseNodeDescriptor")
BrowseNodeDescriptor0.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
'BrowseNodeDescriptor0.NodeDescriptor.NodeId.StandardName = "Objects"

' Set the starting node of the first dialog, show the first dialog, and let the user select a first node.

Dim BrowseDialog1: Set BrowseDialog1 = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
Set BrowseDialog1.InputsOutputs.CurrentNodeDescriptor = BrowseNodeDescriptor0
Dim dialogResult1: dialogResult1 = BrowseDialog1.ShowDialog
If dialogResult1 <> DialogResult_OK Then
    WScript.Quit
End If
Dim BrowseNodeDescriptor1: Set BrowseNodeDescriptor1 = BrowseDialog1.InputsOutputs.CurrentNodeDescriptor

' Display the first node chosen.

WScript.Echo
WScript.Echo BrowseNodeDescriptor1.NodeDescriptor.NodeId
WScript.Echo BrowseNodeDescriptor1.NodeDescriptor.BrowsePath

' Set the starting node of the second dialog to be the node chosen by the user before, show the second dialog, and let the
' use select a second node.

Dim BrowseDialog2: Set BrowseDialog2 = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
Set BrowseDialog2.InputsOutputs.CurrentNodeDescriptor = BrowseNodeDescriptor1
Dim dialogResult2: dialogResult2 = BrowseDialog2.ShowDialog
If dialogResult2 <> DialogResult_OK Then
    WScript.Quit
End If
Dim BrowseNodeDescriptor2: Set BrowseNodeDescriptor2 = BrowseDialog2.InputsOutputs.CurrentNodeDescriptor

' Display the second node chosen.

WScript.Echo
WScript.Echo BrowseNodeDescriptor2.NodeDescriptor.NodeId
WScript.Echo BrowseNodeDescriptor2.NodeDescriptor.BrowsePath

 

Similarly, this can be achieved with multi-selection as well.

.NET

// This example shows how the current node and selected nodes can be persisted between dialog invocations.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UABrowseDialog
{
    static partial class ShowDialog
    {
        public static void SelectionDescriptors(IWin32Window owner)
        {
            // The variables that persist the current and selected nodes.

            var currentNodeDescriptor = new UABrowseNodeDescriptor();
            var selectionDescriptors = new UABrowseNodeDescriptorCollection();

            // The initial current node (optional).

            currentNodeDescriptor.EndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";

            // Repeatedly show the dialog until the user cancels it.

            do
            {
                var browseDialog = new UABrowseDialog();
                browseDialog.Mode.MultiSelect = true;

                // Set the dialog inputs from the persistence variables.

                browseDialog.InputsOutputs.CurrentNodeDescriptor = currentNodeDescriptor;
                browseDialog.InputsOutputs.SelectionDescriptors.Clear();
                foreach (UABrowseNodeDescriptor browseNodeDescriptor in selectionDescriptors)
                    browseDialog.InputsOutputs.SelectionDescriptors.Add(browseNodeDescriptor);

                DialogResult dialogResult = browseDialog.ShowDialog(owner);
                if (dialogResult != DialogResult.OK)
                    break;

                // Update the persistence variables with the dialog output.

                currentNodeDescriptor = browseDialog.InputsOutputs.CurrentNodeDescriptor;
                selectionDescriptors.Clear();
                foreach (UABrowseNodeDescriptor browseNodeDescriptor in browseDialog.InputsOutputs.SelectionDescriptors)
                    selectionDescriptors.Add(browseNodeDescriptor);

            } while (true);
        }
    }
}
# This example shows how the current node and selected nodes can be persisted between dialog invocations.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


# The variables that persist the current and selected nodes.
currentNodeDescriptor = UABrowseNodeDescriptor()
selectionDescriptors = UABrowseNodeDescriptorCollection()

# The initial current node (optional).

currentNodeDescriptor.EndpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')

# Repeatedly show the dialog until the user cancels it.

while True:
    browseDialog = UABrowseDialog()
    browseDialog.Mode.MultiSelect = True

    # Set the dialog inputs from the persistence variables.

    browseDialog.InputsOutputs.CurrentNodeDescriptor = currentNodeDescriptor
    browseDialog.InputsOutputs.SelectionDescriptors.Clear()
    for browseNodeDescriptor in selectionDescriptors:
        browseDialog.InputsOutputs.SelectionDescriptors.Add(browseNodeDescriptor)

    dialogResult = browseDialog.ShowDialog()
    print(dialogResult)
    if dialogResult != DialogResult.OK:
        break

    # Update the persistence variables with the dialog output.

    currentNodeDescriptor = browseDialog.InputsOutputs.CurrentNodeDescriptor
    selectionDescriptors.Clear()
    for browseNodeDescriptor in browseDialog.InputsOutputs.SelectionDescriptors:
        selectionDescriptors.Add(browseNodeDescriptor)

print('Finished.')

COM

Rem This example shows how the current node and selected nodes can be persisted between dialog invocations.

Option Explicit

Const DialogResult_OK = 1

' The variables that persist the current and selected nodes.

Dim CurrentNodeDescriptor: Set CurrentNodeDescriptor = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseNodeDescriptor")
Dim SelectionDescriptors: Set SelectionDescriptors = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseNodeDescriptorCollection")

' The initial current node (optional).

CurrentNodeDescriptor.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"

' Repeatedly show the dialog until the user cancels it.

Do
    Dim BrowseDialog: Set BrowseDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
    BrowseDialog.Mode.MultiSelect = True

    ' Set the dialog inputs from the persistence variables.

    Set BrowseDialog.InputsOutputs.CurrentNodeDescriptor = CurrentNodeDescriptor
    BrowseDialog.InputsOutputs.SelectionDescriptors.Clear
    Dim BrowseNodeDescriptor: For Each BrowseNodeDescriptor In SelectionDescriptors
        BrowseDialog.InputsOutputs.SelectionDescriptors.Add BrowseNodeDescriptor
    Next

    Dim dialogResult1: dialogResult1 = BrowseDialog.ShowDialog
    If dialogResult1 <> DialogResult_OK Then
        Exit Do
    End If

    ' Update the persistence variables with the dialog output.

    Set CurrentNodeDescriptor = BrowseDialog.InputsOutputs.CurrentNodeDescriptor
    selectionDescriptors.Clear
    For Each BrowseNodeDescriptor In BrowseDialog.InputsOutputs.SelectionDescriptors
        SelectionDescriptors.Add BrowseNodeDescriptor
    Next

Loop While True

 

Advanced

There are also ways to control some finer aspects of the dialog. For example, the Mode.ShowListBranches property (defaults to true) controls whether the branches of the tree are also displayed in the list view.

When you set the Simulated property of the dialog to true, the dialog will provide its contents from a pre-defined, simulated view of the world, with fake networks, computers, OPC servers, and their contents. This can be useful for experimentation and testing, either by the developer during the design (right in Visual Studio), or by the end-user (if you expose this functionality in your application), when the environment is not accessible.

If you want to change the parameters of the client object the component uses to perform its OPC operations, you can use the ClientSelector Property.

 

 

Example

.NET

COM

COM

// This example shows how to let the user browse for an OPC-UA node.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UABrowseDialog
{
    static partial class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var browseDialog = new UABrowseDialog();
            browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com";
            browseDialog.Mode.AnchorElementType = UAElementType.Host;

            DialogResult dialogResult = browseDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, browseDialog.Outputs.CurrentNodeElement.NodeElement.ToString());
        }
    }
}
# This example shows how to let the user browse for an OPC-UA node.

using namespace OpcLabs.EasyOpc.UA.Forms.Browsing

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

# Instantiate the dialog object.
$browseDialog = New-Object UABrowseDialog
$browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
$browseDialog.Mode.AnchorElementType = [UAElementType]::Host

$dialogResult = $browseDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
Write-Host $browseDialog.Outputs.CurrentNodeElement.NodeElement
# This example shows how to let the user browse for an OPC-UA node.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


browseDialog = UABrowseDialog()
browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = 'opcua.demo-this.com'
browseDialog.Mode.AnchorElementType = UAElementType.Host

dialogResult = browseDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print(browseDialog.Outputs.CurrentNodeElement.NodeElement)

print('Finished.')
// This example shows how to let the user browse for an OPC-UA node.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UABrowseDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UABrowseDialogPtr BrowseDialogPtr(__uuidof(UABrowseDialog));

            //
            BrowseDialogPtr->InputsOutputs->CurrentNodeDescriptor->EndpointDescriptor->Host = L"opcua.demo-this.com";
            BrowseDialogPtr->Mode->AnchorElementType = UAElementType_Host;

            // 
            DialogResult dialogResult = BrowseDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(BrowseDialogPtr->Outputs->CurrentNodeElement->NodeElement->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for an OPC-UA node.

class procedure ShowDialog.Main;
var
  BrowseDialog: OpcLabs_EasyOpcForms_TLB._UABrowseDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
begin
  // Instantiate the dialog object
  BrowseDialog := CoUABrowseDialog.Create;
  BrowseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host := 'opcua.demo-this.com';
  BrowseDialog.Mode.AnchorElementType := UAElementType_Host;

  DialogResult := BrowseDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  WriteLn(BrowseDialog.Outputs.CurrentNodeElement.NodeElement.ToString);
end;
// This example shows how to let the user browse for an OPC-UA node.

$UAElementType_Host = 1;

$BrowseDialog = new COM("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog");
$BrowseDialog->InputsOutputs->CurrentNodeDescriptor->EndpointDescriptor->Host = "opcua.demo-this.com";
$BrowseDialog->Mode->AnchorElementType = $UAElementType_Host;

printf("%d\n", $BrowseDialog->ShowDialog);

// Display results
printf("%s\n", $BrowseDialog->Outputs->CurrentNodeElement->NodeElement);
# This example shows how to let the user browse for an OPC-UA node.

# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
import win32com.client

UAElementType_Host = 1

browseDialog = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.Forms.Browsing.Specialized.UABrowseDialog') 
browseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
browseDialog.Mode.AnchorElementType = UAElementType_Host

print(browseDialog.ShowDialog())

# Display results
print(browseDialog.Outputs.CurrentNodeElement.NodeElement)
Rem This example shows how to let the user browse for an OPC-UA node.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim BrowseDialog As New UABrowseDialog
    BrowseDialog.InputsOutputs.CurrentNodeDescriptor.endpointDescriptor.Host = "opcua.demo-this.com"
    
    Dim DialogResult
    DialogResult = BrowseDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & BrowseDialog.outputs.CurrentNodeElement.NodeElement & vbCrLf
End Sub
Rem This example shows how to let the user browse for an OPC-UA node.

Option Explicit

Const DialogResult_OK = 1

Const UAElementType_Host = 1

Dim BrowseDialog: Set BrowseDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
BrowseDialog.InputsOutputs.CurrentNodeDescriptor.EndpointDescriptor.Host = "opcua.demo-this.com"
BrowseDialog.Mode.AnchorElementType = UAElementType_Host

Dim dialogResult: dialogResult = BrowseDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo BrowseDialog.Outputs.CurrentNodeElement.NodeElement
Rem This example shows use the output data (node) from one dialog invocation as input data in a subsequent dialog 
Rem invocation.

Option Explicit

Const DialogResult_OK = 1

' Define the starting node for the first dialog.

Dim BrowseNodeDescriptor0: Set BrowseNodeDescriptor0 = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseNodeDescriptor")
BrowseNodeDescriptor0.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
'BrowseNodeDescriptor0.NodeDescriptor.NodeId.StandardName = "Objects"

' Set the starting node of the first dialog, show the first dialog, and let the user select a first node.

Dim BrowseDialog1: Set BrowseDialog1 = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
Set BrowseDialog1.InputsOutputs.CurrentNodeDescriptor = BrowseNodeDescriptor0
Dim dialogResult1: dialogResult1 = BrowseDialog1.ShowDialog
If dialogResult1 <> DialogResult_OK Then
    WScript.Quit
End If
Dim BrowseNodeDescriptor1: Set BrowseNodeDescriptor1 = BrowseDialog1.InputsOutputs.CurrentNodeDescriptor

' Display the first node chosen.

WScript.Echo
WScript.Echo BrowseNodeDescriptor1.NodeDescriptor.NodeId
WScript.Echo BrowseNodeDescriptor1.NodeDescriptor.BrowsePath

' Set the starting node of the second dialog to be the node chosen by the user before, show the second dialog, and let the
' use select a second node.

Dim BrowseDialog2: Set BrowseDialog2 = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog")
Set BrowseDialog2.InputsOutputs.CurrentNodeDescriptor = BrowseNodeDescriptor1
Dim dialogResult2: dialogResult2 = BrowseDialog2.ShowDialog
If dialogResult2 <> DialogResult_OK Then
    WScript.Quit
End If
Dim BrowseNodeDescriptor2: Set BrowseNodeDescriptor2 = BrowseDialog2.InputsOutputs.CurrentNodeDescriptor

' Display the second node chosen.

WScript.Echo
WScript.Echo BrowseNodeDescriptor2.NodeDescriptor.NodeId
WScript.Echo BrowseNodeDescriptor2.NodeDescriptor.BrowsePath
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.CommonDialog
            OpcLabs.BaseLib.Forms.ConcreteCommonDialog
               OpcLabs.BaseLib.Forms.FormCommonDialog
                  OpcLabs.BaseLib.Forms.SizableCommonDialog
                     OpcLabs.BaseLib.Forms.Browsing.Generalized.BrowseDialog
                        OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseDialog

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also