tboy6423
asked on
Passing the selected item in a combobox to a text field on another form..
In the app that I am creating using Visual Studios 2008, vb.net, I have a Main form and a sub form that opens to do a search. On that search form it has a combobox that pulls data from a dataset and populates the corresponding textboxes with data. What I am trying to do is pass that data on the search form to the Main form (to the appropriate textboxes) on a button click. Below is the code I am using:
Private Sub btnAddBillcompany_Click(By Val sender As System.Object, ByVal e As System.EventArgs) Handles btnAddBillcompany.Click
MainForm.txtCoNameBill.Tex t = Me.ComboBox1.SelectedItem. ToString
Me.Hide()
End Sub
When I run this I select the company name, and click the button, the window hides but the textbox on the main form is not populated with the selected text... Any help would be appreciated!!!
Private Sub btnAddBillcompany_Click(By
MainForm.txtCoNameBill.Tex
Me.Hide()
End Sub
When I run this I select the company name, and click the button, the window hides but the textbox on the main form is not populated with the selected text... Any help would be appreciated!!!
If you add a breakpoint at " MainForm.txtCoNameBill.Tex t = Me.ComboBox1.SelectedItem. ToString" can you confirm that a value is actually being retrieved from the ComboBox? Maybe print Me.ComboBox1.SelectedItem. ToString to the debug console, and see what the output it.
MainForm.txtCoNameBill.Tex t = Me.ComboBox1.text
cheers
Lex
cheers
Lex
MainForm.txtCoNameBill.Tex t = Me.ComboBox1.SelectedText
ASKER
Thank you all for your suggestions, but I have tried those...
If you add a breakpoint at " MainForm.txtCoNameBill.Tex t = Me.ComboBox1.SelectedItem. ToString" can you confirm that a value is actually being retrieved from the ComboBox? I created code similar to yours and it worked fine.
ASKER
Does it matter that I am using a dataset that populates that combobox? Also don't I have to do something to the other form..the one that will be populated with the data? I added a breakpoint but no errors...
Did you try setting the modifier of the txtCoNameBill textbox property to Public?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.