Lars Persson

Lars Persson

  • NA
  • 110
  • 0

Sending data between forms

Oct 15 2012 7:00 AM
I have a form where a set a variable "account".

Then I create another form and send the variable to that form in a constructor like this:

form f2 = new Form2(account);

f2.ShowDialog();

 

In the form-class f2 I have a button where I write what I want to withdraw from the account.

   


private void withDraw_Click(object sender, EventArgs e

{

        deposit = Int.Parse(txtDeposit.Text);

}

The constructor:

    public Form2(int account)
    {
            InitializeComponent();

            account = account + deposit;
    }

What I want is to write the amount to deposit in the account in the textbox.

That amount I want to add to the account-variable.

Then I want to return the account to the mainform.

But I dont now how to do that or maybe I could use some global variable?







     







Answers (8)