OPC Studio User's Guide and Reference
UABrowseNodeDescriptorCollection Class
Members  Example 



OpcLabs.EasyOpcForms Assembly > OpcLabs.EasyOpc.UA.Forms.Browsing Namespace : UABrowseNodeDescriptorCollection Class
A collection of UABrowseNodeDescriptors.
Object Model
UABrowseNodeDescriptorCollection ClassUABrowseNodeDescriptor Class
Syntax
'Usage
 
Dim instance As UABrowseNodeDescriptorCollection
Example
// This example shows how the current node and selected nodes can be persisted between dialog invocations.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

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.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.UA.Forms.Browsing

Namespace UAFormsDocExamples._UABrowseDialog
    Partial Friend Class ShowDialog
        Shared Sub SelectionDescriptors(owner As IWin32Window)
            ' The variables that persist the current and selected nodes.

            Dim currentNodeDescriptor = New UABrowseNodeDescriptor()
            Dim 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
                Dim browseDialog = New UABrowseDialog()
                browseDialog.Mode.MultiSelect = True

                ' Set the dialog inputs from the persistence variables.

                browseDialog.InputsOutputs.CurrentNodeDescriptor = currentNodeDescriptor
                browseDialog.InputsOutputs.SelectionDescriptors.Clear()

                For Each browseNodeDescriptor As UABrowseNodeDescriptor In selectionDescriptors
                    browseDialog.InputsOutputs.SelectionDescriptors.Add(browseNodeDescriptor)
                Next browseNodeDescriptor

                Dim dialogResult As DialogResult = browseDialog.ShowDialog(owner)
                If dialogResult <> DialogResult.OK Then
                    Exit Do
                End If

                ' Update the persistence variables with the dialog output.

                currentNodeDescriptor = browseDialog.InputsOutputs.CurrentNodeDescriptor
                selectionDescriptors.Clear()
                For Each browseNodeDescriptor As UABrowseNodeDescriptor In browseDialog.InputsOutputs.SelectionDescriptors
                    selectionDescriptors.Add(browseNodeDescriptor)
                Next browseNodeDescriptor
            Loop While True
        End Sub
    End Class
End Namespace
Rem This example shows how the current node and selected nodes can be persisted between dialog invocations.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

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
# This example shows how the current node and selected nodes can be persisted between dialog invocations.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# 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.')
Inheritance Hierarchy

System.Object
   System.Collections.ObjectModel.Collection<T>
      System.Collections.ObjectModel.ObservableCollection<T>
         OpcLabs.EasyOpc.UA.Forms.Browsing.UABrowseNodeDescriptorCollection

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