Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Nested datagridview control in VB.NET

Posted on 2014-03-04
5
Medium Priority
?
1,945 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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