private void ListboxAccount_SelectionChanged(object sender, SelectionChangedEventArgs e) { Accounts SelectedAccount = ListboxAccount.SelectedItem as Accounts; //getting the selected Account CurrentAccount SelectedCurrent = ListboxAccount.SelectedItem as CurrentAccount; SavingAccount SelectedSaving = ListboxAccount.SelectedItem as SavingAccount; if (SelectedAccount != null) // as long as there is an account that is selected { FirstnameTBX.Text = SelectedAccount.FirstName; //prints the data of that account in the corilated boxs LastnameTBX.Text = SelectedAccount.LastName; BalanceTBX.Text = SelectedAccount.Balance.ToString(); InterestDateTBX.Text = SelectedAccount.InterestDate; } }
private void ListBox_Loaded(object sender, RoutedEventArgs e) { Accounts e1 = new SavingAccount("jeff", "bosoz", 21, "21/12/2021"); //making the people in the Accounts class SavingAccount e1v2 = new SavingAccount("jeff", "bosoz", 21, "21/12/2021"); //making the people for that group Accounts e2 = new CurrentAccount("elon", "Musk", 543, "11/06/2020"); CurrentAccount e2v2 = new CurrentAccount("elon", "Musk", 543, "11/06/2020"); Accounts e3 = new SavingAccount("jimmy", "netron", 9645, "19/04/2020"); SavingAccount e3v2 = new SavingAccount("jimmy", "netron", 9645, "19/04/2020"); Accounts e4 = new CurrentAccount("bart", "simpson", 654, "02/02/2020"); CurrentAccount e4v2 = new CurrentAccount("bart", "simpson", 654, "02/02/2020"); accounts.Add(e1); //adding people to the list for the Accounts class Savingaccountppl.Add(e1v2); //indivisually adding each perosn to ther erespective group at first to help filtering later on accounts.Add(e2); Currentaccountppl.Add(e2v2); accounts.Add(e3); Savingaccountppl.Add(e3v2); accounts.Add(e4); Currentaccountppl.Add(e4v2); ListboxAccount.ItemsSource = accounts; //filling the empty table with just accounts at first }