masterdetail need help !

  • Thread starter Thread starter dfjhsqd
  • Start date Start date
D

dfjhsqd

Hi all

I have a form with 2 datagrids (master-detail)
and a combobox to create a filter for the masterdatagrid.

The master-detail worked fine when i used a dataset like this :

drelRelation = New DataRelation _
("drelMasterDetail", dsMasterDetail.Tables("tblMaster").Columns("ID"), _
dsMasterDetail.Tables("tblDetail").Columns("MasterID"))
dsMasterDetail.Relations.Add(drelRelation)
dtgMaster.SetDataBinding(dsMasterDetail, "tblMaster")
dtgDetail.SetDataBinding(dsMasterDetail, "tblMaster.drelMasterDetail")


BUT now I wanna use the combobox for filtering, so I thought I could use the
DataView and the RowFilter-property

but then i can't get my master-detail part right?????
anyone any idea?
or is there a better way for this? I'm still a newbie

Thanx in Advance
 
You should be able to do this without binding the relation. You can bind
the second control to a dataview based on the datatable ie DataView dv =
dsMasterDetail.Tables("tblDetail").DefaultView;

Then, whever the Selectedindex change fires (or selecteditem - you cn pick
which event you want) then set the RowFilter for dv.Rowfilter = "ID = '" &
combBoxParent.SelectedValue & "'"

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
thx mate
I finally figured it out :-)


William Ryan eMVP said:
You should be able to do this without binding the relation. You can bind
the second control to a dataview based on the datatable ie DataView dv =
dsMasterDetail.Tables("tblDetail").DefaultView;

Then, whever the Selectedindex change fires (or selecteditem - you cn pick
which event you want) then set the RowFilter for dv.Rowfilter = "ID = '" &
combBoxParent.SelectedValue & "'"

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Back
Top