private void btnOpenWebsite_Click(object sender, EventArgs e) { if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ConnectionId = CurrentSelectedID; if (OW.Visible && OW.Text == "Open Website - " + ConnectionId) { } else { OW = new OpenWebsite(); OW.Show(); OW.ConnectionID = ConnectionId; OW.Text = "Open Website - " + OW.ConnectionID; } }
//Open website private void btnOpenWebsite(object sender, EventArgs e) { if (lbConnectedClients.SelectedItems.Count < 0) { MessageBox.Show("Please select a client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int ConnectionId = CurrentSelectedID; foreach (OpenWebsite OW in Application.OpenForms.OfType <OpenWebsite>()) { if (OW.Visible && OW.ConnectionID == ConnectionId) { return; } } OW = new OpenWebsite(); OW.Show(); OW.ConnectionID = ConnectionId; OW.Text = "Open Website - " + OW.ConnectionID; }