How to pass an argument from one Window Form to another?
Hi,
I'm trying to pass an argument from one window form to another ... but could not do it!!! Have try declaring the variable Public and Shared to no avail. Help!!!
What I am doing is to obtain an id from Form A --- (Click a button on Form A to open Form B) --- passing the argument to Form B so the Load event can look up data base on that id.
Thanks
Re: How to pass an argument from one Window Form to another?
Create properties on your forms
Kind Regards
Jorge
Re: How to pass an argument from one Window Form to another?
If Form A or other objects need to be able to see this value then it should be a public property of Form B, which you can set from Form A. If no other objects need to see the value then you should create a constructor for Form B that takes this value as an argument. If Form B always requires this argument then it can be the only public constructor. In this situation, I usually make the default constructor (found near the top of the auto-generated code) private and then call it from any other constructors I create. You can, of course, create a constructor and public property.