private void btnRemove_Click(object sender, System.EventArgs e) { this.Cursor = Cursors.WaitCursor; try { jabber.JID jid = new jabber.JID(txtEntry.Text); int i = 0; foreach (object o in lstJID.Items) { if (jid.Equals(o)) { lstJID.Items.RemoveAt(i); txtEntry.Clear(); error.SetError(txtEntry, null); break; } i++; } } catch (Exception ex) { error.SetError(txtEntry, "Invalid JID: " + ex.ToString()); } this.Cursor = Cursors.Default; }