private void BrowseTV_AfterSelect(object sender, TreeViewEventArgs e)
{
try
{
DeclarationsLV.Items.Clear();
if (e.Node == null)
{
OkBTN.Enabled = false;
return;
}
OkBTN.Enabled = true;
// get the currently selected event.
NodeId typeId = m_rootId;
ReferenceDescription reference = e.Node.Tag as ReferenceDescription;
if (reference != null)
{
typeId = (NodeId)reference.NodeId;
}
// get the instance declarations.
List<InstanceDeclaration> instances = ModelUtils.CollectInstanceDeclarationsForType(m_session, typeId);
// populate the list box.
for (int ii = 0; ii < instances.Count; ii++)
{
InstanceDeclaration instance = instances[ii];
ListViewItem item = new ListViewItem(instance.DisplayPath);
item.SubItems.Add(instance.DataTypeDisplayText);
item.SubItems.Add(instance.Description);
item.Tag = instance;
DeclarationsLV.Items.Add(item);
}
// resize columns to fit text.
for (int ii = 0; ii < DeclarationsLV.Columns.Count; ii++)
{
DeclarationsLV.Columns[ii].Width = -2;
}
}
catch (Exception exception)
{
ClientUtils.HandleException(this.Text, exception);
}
}