Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HowTo: From DataGridView control to ListBox
Message
From
27/03/2007 14:45:24
John Baird
Coatesville, Pennsylvania, United States
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01208957
Message ID:
01208963
Views:
22
I'm assuming that the session table has all the records init. I would filter the sessions data using the SessionBindingSource's filter capability and then either bind the ListView to the dataRowView or loop through the dataRowView and add the items to the ListView items collection.



>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.javascript:MessageSubmit()
[Save this message so it will appear for other members immediately]
>
>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 contains both 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform