Link to home
Start Free TrialLog in
Avatar of IronDriver
IronDriver

asked on

Use listbox with SQL table data to fill remaining form controls upon selection

I have an SQL table, (tblFPDetail), that I would like to retrive data from and display this information in several textboxes on my form. My table has a foreign key (PCIDNum) with another table,(PCinfo). The PCInfo table contains a field, PCName. I would like to be able on my form to have a listbox that shows the PCName values of which the user would select the appropriate one. The remaining textboxes on the form would then fill with the related data from tblFPDetail. The user should then be able modify the values within the textboxes with data from tblFPDetail and select save from the toolstrip and have the values within tblFPDetail be modified.
Thanks in advance for any help!
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

IronDriver,

You understand that what you are asking needs a lot of code to do. I will show you the basics and you can start working with that but it's difficult to explain everything in a post. I will show you how to retrive data from the form and populate the listbox (in the example I use a listview) but you can use that. Check this example that I post it yesterday https://www.experts-exchange.com/questions/23111538/Show-Search-Results-In-Windows-Application-Form.html

Then what you have to do is when the user change the selection on the listview (listview selectedindexchange event) you read again from the db and populate the textboxes.

You can also use a datagridview control and bind using the available wizards. With this you can update/delete and insert direcly in the datagridview.
Avatar of IronDriver
IronDriver

ASKER

Thank you jp for the response...sorry so long to follow up. It has taken me a little while to actually get this to work as you have referenced in some of your prior comments. I have gotten the listview to work fine but that is about half the battle. I have included a diagram in PDF format the better illustrates what I am looking for. I may be headed about this in the wrong manner and if so feel free to let me know a simpler way...or if I am just wayyyyy off.   Thanks!
Simple-Table-Diagram.pdf
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial