Solved

Nested datagridview control in VB.NET

Posted on 2014-03-04
5
1,695 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

13 Experts available now in Live!

Get 1:1 Help Now