I know how to pass an object from parent-form to sub-form using constructors.
For example in the parent form, I do this:
WithdrawDialog dlg = new WithdrawDialog(cust.Accounts);
Child form:
public WithdrawDialog(BankAccountCollection accounts)
{
InitializeComponent();
PopulateComboBox(accounts);
}
// populate comboBox with accounts
private void PopulateComboBox(BankAccountCollection accounts)
{
foreach (BankAccount b in accounts)
{
comboBoxAccount.Items.Add(b);
}
}
I’m still trying to get the hang of Properties… How would I use properties instead of overloaded constructors to do this?
Here you go:
Alternatively, PopupComboBox could be rewritten to use the accounts property: