private void btnRemover_Click(object sender, EventArgs e) { if (selectedRow.HasValue) { try { service.RemoverConsulta(list[selectedRow.Value].Consulta); MessageBox.Show(@"Consulta removida com sucesso!"); //list[selectedRow.Value].writer.Write("Consulta " + list[selectedRow.Value].Consulta.ID_Consulta + " removida com sucesso."); CloseSelectedConnection(list[selectedRow.Value]); list.RemoveAt(selectedRow.Value); Invoke(new MethodInvoker(delegate() { listView1.Items.RemoveAt(selectedRow.Value); })); ClearTextBoxs(); } catch (WebException) { MessageBox.Show(ERROR_WEBSERVICE); } catch (Exception ex) { MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }