private void treeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) { TreeListMultiSelection selection = treeList1.Selection; try { if (selection.Count != 0) { Channel channel = null; Device device = null; DataBlock dataBlock = null; selection[0].ImageIndex = selection[0].Level; switch (selection[0].Level) { case 1: { short num = short.Parse(selection[0]["ChannelId"].ToString()); channel = objChannelManager.GetByChannelId(num); break; } case 2: { TreeListNode treeListNode2 = selection[0]; short num = short.Parse(treeListNode2.ParentNode["ChannelId"].ToString()); short deviceId = short.Parse(treeListNode2["DeviceId"].ToString()); channel = objChannelManager.GetByChannelId(num); device = objDeviceManager.GetByDeviceId(channel, deviceId); break; } case 3: { TreeListNode treeListNode = selection[0]; TreeListNode parentNode = treeListNode.ParentNode; short num = short.Parse(parentNode.ParentNode["ChannelId"].ToString()); short deviceId = short.Parse(parentNode["DeviceId"].ToString()); short dataBlockId = short.Parse(treeListNode["DataBlockId"].ToString()); channel = objChannelManager.GetByChannelId(num); device = objDeviceManager.GetByDeviceId(channel, deviceId); dataBlock = objDataBlockManager.GetByDataBlockId(device, dataBlockId); if (dataBlock.MemoryType == "Datablock") { gvTags.ViewCaption = $"Memory Type: {dataBlock.MemoryType} | DataBlock Name: {dataBlock.DataBlockName} | DataBlock Name: DB{dataBlock.StartAddress}".ToUpper(); } else { gvTags.ViewCaption = $"Memory Type: {dataBlock.MemoryType}".ToUpper(); } bsSource.DataSource = dataBlock.Tags; colTagName.BestFit(); break; } } if (channel == null) { propertyGridChannel.Visible = false; } else { propertyGridChannel.SelectedObject = channel; propertyGridChannel.Visible = true; } if (device != null) { propertyGridDevice.SelectedObject = device; propertyGridDevice.Visible = true; } else { propertyGridDevice.Visible = false; } if (dataBlock != null) { propertyGridDataBlock.SelectedObject = dataBlock; propertyGridDataBlock.Visible = true; if (dataBlock.Tags != null) { lblTagCount.Caption = $"Total: {dataBlock.Tags.Count} tags"; } } else { propertyGridDataBlock.Visible = false; lblTagCount.Caption = $"Total: {0} tags"; lblSelectedTagName.Caption = string.Format("Selected tag: {0}", "None"); } } } catch (Exception ex2) { XtraMessageBox.Show(this, ex2.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }