/// <summary> /// Occurs after an item in the UPnP browser tree view is selected. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The event arguments.</param> private void tvUPnP_AfterSelect(object sender, TreeViewEventArgs e) { // Get the selection tree item. IUPnPTreeItem liItem = tvUPnP.SelectedItem; // Save the currently showed control ctlUPnPInfo liPrev = miInfo; // Default to no new control miInfo = null; try { // If the new item is available if (liItem != null) { // Get the control miInfo = liItem.InfoControl; // If the control is available if (miInfo != null) { // Dock it and add it miInfo.Dock = DockStyle.Fill; pnlInfo.Controls.Add(miInfo); } } } finally { // If the old control was available if (liPrev != null) { // Remove it and dispose it pnlInfo.Controls.Remove(liPrev); liPrev.Dispose(); } } }
/// <summary> /// Occurs after an item in the UPnP browser tree view is selected. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The event arguments.</param> private void tvUPnP_AfterSelect(object sender, TreeViewEventArgs e) { // Get the selection tree item. IUPnPTreeItem liItem = tvUPnP.SelectedItem; // Save the currently showed control ctlUPnPInfo liPrev = miInfo; // Default to no new control miInfo = null; try { // If the new item is available if (liItem != null) { // Get the control miInfo = liItem.InfoControl; // If the control is available if (miInfo != null) { // Dock it and add it miInfo.Dock = DockStyle.Fill; pnlInfo.Controls.Add(miInfo); } } } finally { // If the old control was available if (liPrev != null) { // Remove it and dispose it pnlInfo.Controls.Remove(liPrev); liPrev.Dispose(); } } }