473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HowTo: From DataGridView control to ListBox using one to many rela

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
Mar 28 '07 #1
0 1670

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2416
by: Hugh O | last post by:
Hi, There is a ROW property on the Web Listbox control within VB.Net. The description states it is "The number of visible rows to display". I have tried setting this property in many different...
2
1495
by: Ray | last post by:
Hi, I've just started getting into C# programming and am wanting to develop a small gui that displays a table of files along with their sizes . I am wondering if using the datagridview control...
6
2333
by: =?Utf-8?B?TWFyY2Vsbw==?= | last post by:
Hello, I am new to pulling data into VB and using DataGridViews..... so this might be a dumb question but I can not seem to understand how to make this work. What I need acomplished: Exec a...
1
7764
by: Karl | last post by:
Hi all... This is a good one. You'll like this... I am working on a course management tool that allows certain Courses to be cross referenced with Job Roles and, when they are, whether the...
0
1542
by: Steve Richter | last post by:
I cant get a contextmenu to popup in the context of a datagridview. It pops up in the ListBox, and in the form itself. But not the DataGridView. How could that be? here is my code: using...
1
4911
by: Randy | last post by:
In VS 2005, in the Windows Controls, you have the DataGridView (which has scrollbars). In the WebControls, is the GridView or the DataList synonymous with the DataGridView? Can you have...
2
9200
by: =?Utf-8?B?UGFycm90?= | last post by:
I am trying to implement a drag and drop operation from a listbox to a data gridview control but I keep getting -1 for my row index when the dragdrop function is executed. Below is my coding. ...
6
8722
by: Simon Harvey | last post by:
Hi all, I'm really hoping someone can help me with this as it's causing me some serious problems. I have a Windows Forms application using the gridview control. When the user selects a row,...
0
3008
by: dcollier9 | last post by:
Hi ! I need to embed a text box in a footer of a GridView's boundfield column to get data prior to a row insert. The textbox is usable and showing up in the web page source using View
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.