I have a list of accounts and each account contains name, account number & balance. What I have at the minute is a main form that contains the Account list and the Transaction form button. So when the user selects an account from the list, they can click the button to open the Transaction form. 

What I'm struggling to do is enter a value on the transaction form to add/deduct from the selected account balance... This is updated in the list when it is done. Can someone please help with this?

**Classes:**

* Dashboard.cs - Contains the list and the transaction button that opens the Transaction form.
* Account.cs - Sets the account information.
* Transaction.cs - Passes the data to the account class.
* AccountList.cs - Creates the list.

**Dashboard.cs (Main form):**

```
//Current Desposit/Withdraw button
private void btn_DepositWithdraw_Click(object sender, EventArgs e)
{
    Transaction TransactionForm = new Transaction();

    //Display form but only process results if OK is pressed
    if (TransactionForm.ShowDialog() == DialogResult.OK)
    {
        //Update the item in the list

    }
}

//The selected item in the list
public void list_Accounts_SelectedIndexChanged(object sender, EventArgs e)
{
    //get index of selected account
    int index = list_Accounts.SelectedIndex;
    Account a = (Account)list_Accounts.Items[index];

    //Update text on the Dashboard form
    txt_AccountName.Text = a.AccountName + " #" + a.AccountNo;
    txt_CurrentBalance.Text = "£" + a.Balance;
}

```

**Account.cs:**

```
[Serializable]
    public class Account
    {
        //Set the Variable
        public string AccountName { get; set; }
        public string AccountNo { get; set; }
        public string Balance { get; set; }
        public string Interest { get; set; }
        public string NewBalance { get; set; }

        public Account()
        {
            AccountName = "Account Name not inserted!";
            AccountNo = "Account Number not inserted!";
            Balance = "Balance not inserted!";
        }

        public Account(string name, string accNo, string staBal, string interest)
        {
            AccountName = name;
            AccountNo = accNo;
            Balance = staBal;
            Interest = interest;
        }

        public override string ToString()
        {
            return String.Format("{0} #{1}", AccountName, AccountNo);
        }
    }

    [Serializable]
    public class CurrentAcc : Account
    {

        public CurrentAcc()
        {
        }

        public CurrentAcc(string name, string accNo, string staBal, string interest) : base(name, accNo, staBal, interest)
        {

        }

        public override string ToString()
        {
            return base.ToString() + String.Format("{0,-17}", " (Current Account)");
        }
    }

    [Serializable]
    public class SavingsAcc : Account
    {

        public SavingsAcc()
        {
        }

        public SavingsAcc(string name, string accNo, string staBal, string interest) : base(name, accNo, staBal, interest)
        {

        }

        public override string ToString()
        {
            return base.ToString() + String.Format("{0,-17}", " (Savings Account)");
        }
    }

    [Serializable]
    public class Deposit : Account
    {

    }

    [Serializable]
    public class Withdraw : Account
    {

    }

```

**Transaction.cs:**

```
public string NewTransactionInformation()
{
    Account nt;

    if (radio_Deposit.Checked)
    {
        nt = new Deposit(input_Amount.Text);
    }
    else
    {
        nt = new Withdraw(input_Amount.Text);
    }

    return nt;
}

```

**AccountList.cs:**

```
class AccountList
{
        private List<Account> allaccounts;
        public List<Account> AllAccounts
        {
            get { return allaccounts; }
        }

        public AccountList()
        {
            allaccounts = new List<Account>();
        }

        public void AddCurrent(Account a)
        {
            allaccounts.Add(a);
        }
}

```