Introduction
In the previous lesson we developed an application to manage ourCheckingAccount. In this new lesson we will further expand this application to be able to process the balance of multiple bank accounts. In this lesson we will also introduce a new control: DesktopPopupMenu.
DesktopPopupMenu

The DesktopPopupMenu displays a list of items. The user can select one element from the list. The DesktopPopupMenu will be used to select one of our accounts.
The following Properties are commonly used:
Property | Type | Description |
---|---|---|
LastRowIndex | Integer | The number of the last item in the DesktopPopupMenu (the first element in the list is zero). |
RowCount | Integer | The number of items in the DesktopPopupMenu. |
SelectedRowIndex | Integer | Get or set the selected item number. |
SelectedRowText | String | The text of the selected item. |
The following methods are often used:
Method | Type | Description |
---|---|---|
AddRow(item) | String | Appends the item to the end of the list. |
RemoveAllRows | Removes all elements in the list |
When another item is selected, the following event occurs:
Event | Description |
---|---|
SelectionChanged | Another item in the list has been selected. |
Modifications to the application
Add a DesktopPopupMenu
The DesktopPopupMenu control is available in the library under the Pickers section. Drag this control on the AccountWindow. Change the Name property to AccountPopup.
It is good programming practice to end the name of a DesktopPopupMenu with the suffix 'Popup'.

In the Inspector, you can add items to AccountPopup using the Initial Value property. Initialise the control with the following Strings: CheckingAccount, RetirementAccount and SavingsAccount.
Create new Instances
Add the following Properties to AccountWindow: RetirementAccount and SavingsAccount.
In the Opening event, create instances of the class Account for the newly defined RetirementAccount and SavingsAccount properties:
CheckingAccount = New Account RetirementAccount = New Account SavingsAccount = New Account
DepositButton: Pressed
The account name shown in AccountPopup determines which account should be addressed. The account name is available from the SelectedRowText property:
Var accountName As String accountName = AccountPopup.SelectedRowText Select Case accountName Case "CheckingAccount" CheckingAccount.DepositMoney(1500.00) Case "SavingsAccount" SavingsAccount.DepositMoney(600.00) Case "RetirementAccount" RetirementAccount.DepositMoney(200.00) End
Use camel case (first word in the name is a lower case letter, all subsequent words in the name start with a capital letter) for local variables declared in methods or events.
WithdrawButton: Pressed
The Pressed event for WithdrawButton is quite similar to the Pressed event of DepositButton:
Var accountName As String accountName = AccountPopup.SelectedRowText Select Case accountName Case "CheckingAccount" CheckingAccount.WithdrawMoney(275.00) Case "SavingsAccount" SavingsAccount.WithdrawMoney(150.00) Case "RetirementAccount" RetirementAccount.WithdrawMoney(100.00) End
ShowButton: Pressed
The ShowButton event can be developed in the same way:
Var accountName As String accountName = AccountPopup.SelectedRowText Select Case accountName Case "CheckingAccount" BalanceLabel.Text = "The balance of the checking account = " + _ CheckingAccount.GetBalance.ToString(locale.current) Case "SavingsAccount" BalanceLabel.Text = "The balance of the savings account = " + _ SavingsAccount.GetBalance.ToString(locale.current) Case "RetirementAccount" BalanceLabel.Text = "The balance of the retirement account = " + _ RetirementAccount.GetBalance.ToString(locale.current) End