private void btnEliminaMail_Click(object sender, EventArgs e) { var idMail = (string)treeView1.SelectedNode?.Tag; if (!string.IsNullOrWhiteSpace(idMail)) { if (ConfirmBox.Execute("Sicuro di voler eliminare la mail?", "Conferma")) { AppRepo.RemoveMail(idMail); var n = treeView1.SelectedNode; treeView1.SelectedNode = n.NextNode ?? n.PrevNode; n.Remove(); if (treeView1.SelectedNode == null) { treeView1_AfterSelect(this, null); } } } }