|
-
Oct 23rd, 2004, 02:03 AM
#1
Thread Starter
Frenzied Member
passing a variable value to another form [* Resovled *]
Hello,
I have a form with a variable. I want to be able to send this variable to another form.
Example: i have a customer form and want to send the customer number to the update customer form. So when l click update customer the update customer form will receive the customer number from the customer form.
Hope you understand this.
Many thanks in advance,
Steve
Last edited by steve_rm; Oct 24th, 2004 at 10:40 PM.
steve
-
Oct 23rd, 2004, 04:33 AM
#2
<?="Moderator"?>
I think smething like this has been asked before, and that you need to pass a reference of the first form, to the second in the constructor, and then get the variable from the reference of the passed form. This would let you get and set the variable. Hope it helps
-
Oct 23rd, 2004, 06:57 AM
#3
Frenzied Member
Yes this question has bee asked before. Do a search and you should find something.
-
Oct 24th, 2004, 07:18 PM
#4
PowerPoster
Create a public variable in the EditCustomer form that holds the customer id, something like this:
public int CustomerID;
Then, when you call this form from the main form, you will do something like this:
EditCustomer frm = new EditCustomer();
frm.CustomerID = 55;
frm.ShowDialog();
OR, you can make it as part of the constructor if the form will never operate without a customerid.....
private int _customerID;
public void EditCustomer(int customerID)
{
_customerID = customerID;
}
So when you go to create that form, you have to pass a customerid to it:
EditCustomer frm = new EditCustomer(55);
frm.ShowDialog();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|