Solved

DataGridView with Parent/Child relationship?

Posted on 2014-10-03
3
1,239 Views
Last Modified: 2014-10-11
Is it possible to have a single DataGridView that contains a row with a master record and then contains multiple child records that can be expanded underneath the parent row? If a parent contains no child records, it displays normally, however, if a parent has child records, then place the "+" sign in the DGV RowHeader or somewhere at the beginning of the row to signify child records exist?

Thanks!
0
Comment
Question by:BlakeMcKenna
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 250 total points
ID: 40359563
Hi  BlakeMcKenna;

The DataGridView control found in the Toolbox does not support that type of Master/Detail display option. To do what you would like you will need to use the older control called DataGrid control. You will need to add this control to the Toolbox before it can be used. Microsoft has replaced it with the newer control the DataGridView bit it does not do everything the older control did. To add the DataGrid to the Toolbox you can do the following.

1. In the Toolbox right click on the Tab you wish to place the control in such as the Data tab.
2. Click on the item "Choose Items..."
3. In the new window in the .Net Framework Components find the control DataGrid. Be careful there is also a DataGrid for Web apps. Select the one for Forms.
4. Click on the OK button.

The control is now in the Tab you placed it in and can be dragged onto the design surface.

The Following link will show you how to set it up
Creating Master-Details Lists with the Windows Forms DataGrid Control
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 40363821
Here is an alternative using a TreeView

http://www.codeproject.com/Articles/23746/TreeView-with-Columns
0
 

Author Comment

by:BlakeMcKenna
ID: 40363914
CodeCruiser,

Thank you for the link.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pagebreak issue while printing the aspx page 3 34
vb.net help 4 33
SQL LINE CONTINUATION ISSUE 12 37
Help with preventing selection from a combobox 11 34
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question