private void lvAccounts_SelectedIndexChanged(object sender, EventArgs e) { if (lvAccounts.SelectedItems.Count == 1) { AccountListViewItem alvi = (AccountListViewItem)lvAccounts.SelectedItems[0]; txtAccountName.Text = alvi.Account.AccountName; txtPassword.Text = alvi.Account.Password; txtServer.Text = alvi.Account.Server; switch (alvi.Account.Tribe) { case TribeType.Gaul: rbGauls.Checked = true; rbRomans.Checked = false; rbTeutons.Checked = false; break; case TribeType.Roman: rbGauls.Checked = false; rbRomans.Checked = true; rbTeutons.Checked = false; break; case TribeType.Teutons: rbGauls.Checked = false; rbRomans.Checked = false; rbTeutons.Checked = true; break; } } }
private void btnDeleteAccount_Click(object sender, EventArgs e) { if (lvAccounts.SelectedItems.Count == 1) { AccountListViewItem alvi = (AccountListViewItem)lvAccounts.SelectedItems[0]; DialogResult dialogResult = MessageBox.Show("Are you sure?", "Deletion", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { accountService.Delete(alvi.Account); lvAccounts.Items.Remove(alvi); txtAccountName.Text = string.Empty; txtPassword.Text = string.Empty; txtServer.Text = string.Empty; } } }