473,569 Members | 2,428 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:
PatientsBinding Source, and SessionsBinding Source
4. And, table adapters: PatientTableAda pter, and SessionsTableAd apter
5. Finally, I have the dataset dataSetPatientS essions, which shows the
patients and sessions tables.
6. The DataGridView DataSourcePrope rty is set to patientsBinding Source.
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 1682

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

Similar topics

3
2419
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 ways. It does not appear to do much of anything. I was trying to use it to control the actual size in rows of the list box on the Web page. But...
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 is the way to go or if it is overkill for what I want? (is there something else I should be looking at?) Cheers
6
2337
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 select statement and out put the results to a DataGridView. The columns must be created on the fly as the query may return different fields. A...
1
7768
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 course is a priority course or not. Simple. Because there is alot of data stored for each course, I am using a tab control with several pages. The...
0
1549
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 System; using System.ComponentModel; using System.Data; using System.Drawing;
1
4914
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 scrollbars for the GridView or DataList? Thanks
2
9219
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. DataGridView.HitTestInfo info = dataGridView2.HitTest(e.X, e.Y); int row = info.RowIndex; The coordinates returned to the dragdrop function seem to...
6
8738
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, the SelectionChanged event fires and I load some more data that's particular to that row. The problem I'm having is that the SelectionChanged event...
0
3011
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
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.