Solved

Nested datagridview control in VB.NET

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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