populating text boxes...

G

Guest

in vb.net 2005, i would like to pull up a name from a database (customers) (i
can do this already), then after a name is selected from a combox box, to
populate the form's text boxes with with data about that customer. I.E.: if
john is selected from the combo, i would like to have his address, city, etc.
filled out in the text boxes. I do not want to populate a listbox or
datagrid.....I do these easy as pie in Access but i just can not do it in
vb..... can you please help....i am embarassed on how long i have spent on
this..and just can't get it....wish they had some wizards to create this like
they did in access.. thank you in advance......... :>)
 
B

Bart Mermuys

Hi,

Bill Brinkworth said:
in vb.net 2005, i would like to pull up a name from a database (customers)
(i
can do this already), then after a name is selected from a combox box, to
populate the form's text boxes with with data about that customer. I.E.:
if
john is selected from the combo, i would like to have his address, city,
etc.
filled out in the text boxes. I do not want to populate a listbox or
datagrid.....I do these easy as pie in Access but i just can not do it in
vb..... can you please help....i am embarassed on how long i have spent on
this..and just can't get it....wish they had some wizards to create this
like
they did in access.. thank you in advance......... :>)

1. open "Data Sources window" (menu-data)
2. create a new Data Source for your DB and Table (Customers)
3. inside "Data Sources window" you should now see your DataSet and
DataTable(Customers)
4. next to the Customers table, there should be a dropdown button, click on
it, if you don't see a ComboBox then choose customize and check the
ComboBox, if you do see a ComboBox then select it.
5. drag the Customers table on the Form, this should place a ComboBox on the
Form (and other binding stuff, you may delete the navigator), you can change
the field the ComboBox is showing, by changing DisplayMember ( ComboBox
properties ).
6. inside the "Data Sources window" you should also see all the fields under
the table, so drag any field you want onto the Form.

That should do it, but if you don't or can't go this way, then explain
(maybe with code) how you're already binding the TextBox.

HTH,
Greetings
 
G

Guest

I you don't like binding (and a lot of people don't) then the easiest way
I've found is to use SQL to find the customer information from the customer
name in the database then fill in the text boxes. This can be put into the
combobox.selectedindexchange event. Alternately, you can read the customer
name and info into instance of a classs for each customer when you fill in
the combobox and add instances of this class to the comboboxfor each item.
If you include an override of "ToString" property in the class that returns
the customer name, that's what will appear in the combo box. You can then
use the combobox selecteditem with a directcast to your class and display the
customer info each time the user selects a different customer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top