473,493 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Filtered view on second DataGridView

I have an XML data file with several nested tables two to three layers deep.

I want to use two DataGridViews to show and edit the data then save the data
back to the XML file.

I want the top DataGridView to show the parent data. If clicking any row of
the parent I then want to display in the second DataGridView the nested child
table entries of the parent.

I've looked at BindingSource and filters but I don't understand how to
establish the proper relation in the second DataGridView so that the correct
child tables will correctly display.

Can someone point me in the correct direction on how this is done? Your
help would be very much appreciated!
--
-----------
Thanks,
Steve
Mar 26 '06 #1
3 3337
Hi Steve,

To achieve this, you can try to use the typed DataSet. If the xml data
files are in DataSet format, you can load them into DataSets using
DataSet.ReadXml method. You can also create a DataRelation between the two
related tables.

After a user selects a row in the parent table, you can use
BindingSource.Current to find the current row in the DataSet. Call
DataRow.GetChildRows to get the child rows.

You can also achieve this by using data binding for both parent and child
tables. Please check the following link for an example:

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtskcreatingmasterdetailslistwithdatagrid.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Mar 27 '06 #2
Kevin,

With the direction you provided I was able to come up with the solution that
was quite simple. My code is simply:

private void dataGridViewConceptsA_RowEnter(object sender,
dataGridViewCellEventArgs e)
{
DataRowView dataRowView =
(DataRowView)(((DataGridView)sender).Rows[e.RowIndex]).DataBoundItem;
this.bindingSourceExample.DataSource =
dataRowView.CreateChildView("Concept_Example");
}

This did the trick. Thanks.
--
-----------
Thanks,
Steve
"Kevin Yu [MSFT]" wrote:
Hi Steve,

To achieve this, you can try to use the typed DataSet. If the xml data
files are in DataSet format, you can load them into DataSets using
DataSet.ReadXml method. You can also create a DataRelation between the two
related tables.

After a user selects a row in the parent table, you can use
BindingSource.Current to find the current row in the DataSet. Call
DataRow.GetChildRows to get the child rows.

You can also achieve this by using data binding for both parent and child
tables. Please check the following link for an example:

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtskcreatingmasterdetailslistwithdatagrid.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Mar 29 '06 #3
Hi Steve,

It was nice to hear that you have had the problem resolved. Thanks for
sharing your experience with all the people here. If you have any
questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Mar 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3314
by: s | last post by:
I'm able to get the count of the filtered rows of the dataview from within the With view block, but when I try to bind the view to the listbox I don't get any count within the With lb1 block and my...
6
5196
by: Greg P | last post by:
I am using VS2005 and have been learning a ton about databinding. I know that when you drag a view from the datasource window (creating a dataGridView) that an update method is not added to the...
1
1096
by: Danny M | last post by:
I want to fill a datagridview with a tabel, only problem is one of the fields of this tabel is an ID to another tabel with the name.. I want to also show the name in the grid (they cant edit this...
0
4143
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
10
1739
by: Wildemar Wildenburger | last post by:
Hi there :) I don't know how else to call what I'm currently implementing: An object that behaves like a list but doesn't store it's own items but rather pulls them from a larger list (if they...
2
9993
by: HansP | last post by:
Hi, I am really in a deadlock with this problem. In my VS2005 C# handheld application, I have a grid with Workorders. Another grid (child) are the ACTIONS, performed for each workorder. ...
0
1657
by: Ironr4ge | last post by:
Hi everyone, By the rate its going it want be long till I start growing gray hair... but anyway.. to come to the point... I am trying to open the form "Languages" with a diffrent record...
4
2917
by: Ironr4ge | last post by:
Hi everyone, I am trying to open the form "Languages" with a diffrent record source to the "Contacts" form where I conducted the search or filter... . I was wondering whether there was a vba...
1
1490
by: SunshineInTheRain | last post by:
Dim dtUn As DataTable dtUn= New DataTable dtUn = BindICUN() Dim i As Integer Dim irow As DataRow Dim mailBody As String = "" Dim myRow As...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.