public OpcForm(OutProc anOutProc) { InitializeComponent(); try { m_outProc = anOutProc; m_opcClient = m_outProc.OpcClient; m_session = m_opcClient.GetSession(); m_executionOptions = m_opcClient.GetExecutionOptions(); //create the browse tree root element TreeNode treeRoot = new TreeNode(m_session.Url, 0, 0); DaAddressSpaceElement rootDaAddressSpaceElement = new DaAddressSpaceElement(EnumAddressSpaceElementType.BRANCH, String.Empty, string.Empty, string.Empty, 0, null); rootDaAddressSpaceElement.Session = m_session; treeRoot.Tag = rootDaAddressSpaceElement; itemsTreeView.Nodes.Add(treeRoot); DaAddressSpaceElement[] addressSpaceElements = null; #region Browse branches //--------------------- DaAddressSpaceElementBrowseOptions browseOptions = new DaAddressSpaceElementBrowseOptions(); browseOptions.ElementTypeFilter = EnumAddressSpaceElementType.BRANCH; //get the root's children if (ResultCode.SUCCEEDED(rootDaAddressSpaceElement.Browse( browseOptions, out addressSpaceElements, m_executionOptions))) { if (addressSpaceElements != null) { for (int i = 0; i < addressSpaceElements.Length; i++) { TreeNode node = new TreeNode(addressSpaceElements[i].Name, 1, 1); node.Tag = addressSpaceElements[i]; treeRoot.Nodes.Add(node); } //end for } } //end if //- #endregion addressSpaceElements = null; #region Browse Leaves //------------------- browseOptions.ElementTypeFilter = EnumAddressSpaceElementType.LEAF; //get the root's children if (ResultCode.SUCCEEDED(rootDaAddressSpaceElement.Browse( browseOptions, out addressSpaceElements, m_executionOptions))) { if (addressSpaceElements != null) { for (int i = 0; i < addressSpaceElements.Length; i++) { TreeNode node = new TreeNode(addressSpaceElements[i].Name, 2, 2); node.Tag = addressSpaceElements[i]; treeRoot.Nodes.Add(node); } //end for } // end if } //end if //- #endregion #region GetDaProperties //--------------------- DaProperty[] daProperties = null; m_propertyGetOptions.WhatPropertyData = EnumPropertyData.NONE; if (ResultCode.SUCCEEDED(rootDaAddressSpaceElement.GetDaProperties( m_propertyGetOptions, out daProperties, m_executionOptions))) { if (daProperties != null) { for (int i = 0; i < daProperties.Length; i++) { TreeNode node = new TreeNode(daProperties[i].Name, 3, 3); //add all properties except OPC-specific properties if (daProperties[i].Id >= 100) { treeRoot.Nodes.Add(node); } } //end for } } // end if //- #endregion } catch (Exception exc) { MessageBox.Show(exc.ToString()); } // end try...catch } // end constructor