I am a .NET newbie, specifically WinForms. I have a simple Winform for which
I have a "How To" question:
My WinForm app will display data from a FoxPro database, two tables in
particular: Patients, and Sessions. There is one record in the Patients table
for each patient. The PatientID is the primary key. The sessions table
contains all of the visits that all of the patients have made to the lab.
There is a one-to-many relation between the Patients table and the Sessions
table. Each record in the Sessions table contains a PatientID that associates
that visit in the lab with a particular patient.
I want to display the contents of the Patients table in a DataGridView
control. When the user clicks on a particular patient, I want a ListView
control on the form to display the dates (from the Sessions table) when that
patient appeared in the lab.
Sounds simple enough. I've done quite a bit of experimenting with this using
the Visual Studio 2005 C# designer, so I may have screwed things up. But,
here is what I have so far:
1. I have the DataGridView and ListView controls on the form.
2. I have a working connection string to the database.
3. I have fiddled with BindingSources. I now have two:
PatientsBindingSource, and SessionsBindingSource
4. And, table adapters: PatientTableAdapter, and SessionsTableAdapter
5. Finally, I have the dataset dataSetPatientSessions, which shows the
patients and sessions tables.
6. The DataGridView DataSourceProperty is set to patientsBindingSource.
7. I can compile and run the program. The DataGridView shows the contents of
the Patients table.
8. As a test, I have put a textbox on the form, and bound it to the same
bindingsource used by the DataGridView. When the user clicks on a patient
record in the gridview, I can see that patient's last name in the textbox.
9. How do I get the ListBox to display all of the dates in the sessions
table for the seleced patient?
Thanks in advance for your help.
Jim