Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Nested Datatables in a single DataGridView

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    88

    Resolved [RESOLVED] [2005] Nested Datatables in a single DataGridView

    Greetings. Is there a way to nest two Datatables in a single Datagridview so that the data is displayed like so:

    + Parent Row #1
    - Parent Row #2
    . - Child Row related to Parent Row #2 (1)
    . - Child Row related to Parent Row #2 (2)
    . - Child Row related to Parent Row #2 (3)
    + Parent Row #3
    + Parent Row #4

    I have an example of something similar using a DataGrid, but can not find a reference to this with the DataGridView. Here is the code used with the DataGrid:
    Code:
         Dim student_is_relation As DataRelation = _
           scores_dataset.Relations.Add( _
           "Student Test Scores", _
           students_table.Columns("StudentId"), _
           test_scores_table.Columns("StudentId"))
           
         student_is_relation.Nested = True
    
         grdScores.DataSource = scores_dataset

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Nested Datatables in a single DataGridView

    The DataGridView does not support that functionality.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    88

    Re: [2005] Nested Datatables in a single DataGridView

    With the DataGridView set up as the replacement for the DataGrid, is there any reason why I should not use the DataGrid (problems that I may not be aware of)?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Nested Datatables in a single DataGridView

    This is the major deficiency of the DataGridView class in my opinion. Given that it's an improvement on the DataGrid in basically every other way I would have expected improved relationship navigation, not worse. I was very disappointed when I discovered this. It's not a feature that gets used all the time, which is why I guess they felt justified leaving it out, but it would have been nice.

    Anyway, if you want such navigation then it's the DataGrid or a third-party offering, which is likely to be not cheap. The DataGrid is a b*gger to custimise compared to the DataGridView and doesn't have as attractive UI, but what can you do?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    88

    Cool Re: [2005] Nested Datatables in a single DataGridView

    This feature would have been very nice for my app, but I can live with two related DGVs. Thanks you’re your thoughts on this subject.

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width