// klikniecie przycisku 'refresh' private void button1_Click(object sender, EventArgs e) { AccountManagement am = new AccountManagement(); AccountList.BeginUpdate(); AccountList.Items.Clear(); foreach (Account acc in am.GetAllAccounts()) { AccountList.Items.Add(acc.id + " - " + acc.login + " - " + acc.email + " - " + acc.type.ToString()); } AccountList.EndUpdate(); }
// przycisk 'delete' private void DeleteButton_Click(object sender, EventArgs e) { // pobierz ID zaznaczonego obiektu int id = getIdOfSelectedAccount(); if (id != -1) { AccountManagement am = new AccountManagement(); am.DeleteAccountByID(id); AccountList.BeginUpdate(); AccountList.Items.Remove(AccountList.SelectedItem); AccountList.EndUpdate(); } }