passing a parameter to a new form?

  • Thread starter Thread starter Peter Demeyer
  • Start date Start date
P

Peter Demeyer

Hi,
I want to pass a variable to a new form like this:
MyForm form1= new MyForm(customerid);
and the form is defined like this:
public MyForm(int customerid)
but I want this variable to be available in the MyForm_Load class as
well because this variable must be a comboBox's SelectedValue. If I put
"cmbBox1.SelectedValue=customerid" in the form constructor, then it's
overwritten by MyForm_Load..
I don't see how I can declare this variable outside the form
constructor.
Thanks.
 
Declare a private variable in the form class.
Assign the variable in the Form's constructor
Use it in the Form_Load method.
 
Thank you!
So simple really..

H-S schreef:
Declare a private variable in the form class.
Assign the variable in the Form's constructor
Use it in the Form_Load method.
 
Back
Top