Solved

Nested datagridview control in VB.NET

Posted on 2014-03-04
5
1,628 Views
Last Modified: 2014-03-05
Hi all.

I have a datagridview control in Visual Studio 2008 that displays "header" information, but I want to be able to display "detail" information for each row in the datagridview control when the user clicks it. I have attached a screenshot of what the datagridview control looks like right now. Each MasterItemNumber has more than one price details.

For example:

MasterItemNumber: productABC
Price1: $4
Price2: $5.50
Price3: $6

I don't want to display 3 rows with the same header information to be able to show the 3 prices. Instead I would like to show 1 row for each MasterItemNumber and if the end user clicks or double clicks a row then it will display some kind of nested datagridview control with the 3 prices or 4 or 5 prices etc. It is a Windows Form.

Is this possible? If not, what are my alternatives?

Thank you in advance.
0
Comment
Question by:printmedia
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39904799
I have not done it with a datagridview control, but with a gridview control. I used this MSDN page as a guideline.

Basically you nest the 'detail' grid as a Templatefield and use the primary key from the parent grid to query the details.

http://msdn.microsoft.com/en-us/library/aa992038(v=vs.90).aspx
0
 

Author Comment

by:printmedia
ID: 39904809
Thank you. But that is for a web form, the GridView control is not available for Windows Form.
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39904843
Windows Form version, sorry I missed that line in your question. I submitted a request for attention to see if we can get others involved. I don't do much with the Windows Form apps.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39905725
A grid is interesting to display a certain number of records, but a form is better for only one.

So personnaly, instead of opening a second DataGridView, I prefer to popup a small form or a UserControl that is invisible by default. I react to the RowHeaderMouseClick or RowHeaderMouseDoubleClick, fill the form with the content of the row and make it visible. If the user can edit it, I copy the content of the form in the row when the form is closed.

It would also offer an alternative way of seeing and modifying the data that could be more pleasing to some users.

If the users perform data entry and editing, a form is usually a better interface than a grid. The diversity of controls enables you to display calendars and RadioButtons for instance, that can make data entry a lot easier and less prone to errors. Using a ComboBox in a form is a better experience than the stupid ComboBox of the DataGridView.
0
 

Author Closing Comment

by:printmedia
ID: 39906587
Thanks James.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now