How to: Pass a variable value of a form to another form?

  • Thread starter Thread starter [ F e r n a n d o L o p e s ]
  • Start date Start date
F

[ F e r n a n d o L o p e s ]

Hello ALL,
I have two forms (frmCustomers, frmOpenCustomers)
In the frmOpenCustomers, i have a DataGrid fill with the Customers name.
I show the frmOpenCustomers form from the frmCustomers form like that:

frmOpenCustomers opCust = new frmOpenCustomers();
opCust.ShowDialog();

After I click the row of the customers grid in the opCust form, I need to
close this and show the name of the customer in a public TextBox in the
frmCustomers form.
But nothing appears.

What Am doing wrong?

Thanks in advance.
Sorry my English.

Fernando Lopes
Brazil
 
Fernando,
After I click the row of the customers grid in the opCust form, I need to
close this and show the name of the customer in a public TextBox in the
frmCustomers form.

There's a few ways you can solve this problem. Here's one way:

1. Create an application-level static property called CurrentCustomer
2. When the user launches the modal dialog, clear this property
3. When the user selects a customer in the modal form, store the value in
this static property
4. When the modal form is closed and the calling form continues execution,
retrieve the selected value from this static property

Regards,
Kevin McNeish
C# MVP
Chief Software Architect, Mere Mortals .NET Framework
www.oakleafsd.com
 
Back
Top