Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Parent - Child forms (DataView applied only to Child Records)
 

Parent - Child forms (DataView applied only to Child Records)

Hello,

I'm working in VS 2005 VB.

I have a windows form with datagridview. The DataSource is filtered based on a relation. On the Load Event of the form I would like to create a Dataview that uses the filtered child set of records displayed in the DataGridView and display a subset of those records.

I don't know how to reference the current set of child records to then apply the dataview to. Is that possible?

My code is:


Dim dv As New DataView(DataSet.Relations("rlBParentChildAll").ChildTable)

' A filter statement to be applied to the Child Records

dv.RowFilter = "PrimaryAddress = 0"

'Make the dataview the Recordsourcefor the datagridview

dgAddressesAll.DataSource = dv


The DataGridView now has all the records in the Child Table that match the criteria. Not the child records with the Filter.

Is this possible to just apply a DataView to Child records to further filter them?

Thanks for your thoughts

Earnest Developer  Friday, April 07, 2006 9:53 PM

As far as I remember DataRelation.ChildTable returns just the child table of this relation. Tocreate a DataViewthat containschild rows for a particular parent row, you may use something like:

Dim dv As New DataView(dtChildTable, "ForeignKey = key", "ChildTableColumnToSort", DataViewRowState.CurrentRows)

After that you may apply additional filters to the DataView.

vkh75  Monday, April 10, 2006 12:08 PM

You can use google to search for other answers

Custom Search

More Threads

• column read-only except for the addnew row?
• Edit AccessDatabase with visual c++ .net;
• DataGridView - ArgumentOutOfRangeException
• how to change the link text of a Datagridviewlinkcolumn
• DataGridView strange behaviour!
• Saving the Changes to DB from Datagridview
• DataGridView: Prevent CellEnter?
• Selectively making bound controls Read Only
• datagridview to microsoft excel
• Problem With Data Configuration Wizard and Forms with Generics