?
Solved

Nested datagridview control in VB.NET

Posted on 2014-03-04
5
Medium Priority
?
1,889 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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 Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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