private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedUCDev != null) { IDevices dev = (IDevices)selectedUCDev.Tag; dev.Close(); } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("是否确定要删除此项?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { ListViewItem item = this.listView1.SelectedItems[0]; IDevices dev = (IDevices)item.Tag; if (dev.State == DevicesState.Opened) { dev.Close(); } this.listView1.Items.Remove(item); Devices.DevicesCollection.Remove(dev); } }