Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a combo box value 2

Status
Not open for further replies.

jlitondo

MIS
Jun 27, 2000
175
US
New to .Net and I'm not sure how to do this. I have a form1 with a combobox1 and a command button1.A user makes a selection in the combo then clicks button1 to open form2.
However, how would form2 get access to the value entered in combo1 of form1? I'm trying to use that value as a parameter to a stored procedure that is being used to fill controls on form2.
I tried to work this by creating a form1 object in the form2 class and then using this object to reference the DisplayMember property of combo1 which didn't work so I tried a couple of other properties to no avail. Both forms remain open at the same time.
Thanks in advance.
 
Well you could make a public method in your form2. Call it AcceptData(ComboValue as String) or something like that.

When you click your button on Form1, do something like this:

Dim F2 as new Form2()
F2.AcceptData(Combo.Text)
F2.Show


You've set the value in Form2 before you've displayed it. Within the AcceptData method, you can do anything you want with it: assign it to a private variable, use it in a stored procedure as you've said...etc.
 
Thanks RiverGuy. With a couple of modifications it worked. I use the method to pass and set the values of form2 class variables. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top