DataGridView1. The DataSource=dataSet
DataGridView1. DataMember="master"
DataGridView2. The DataSource=dataSet
DataGridView2. DataMember="master. MasterDetail"
But I also want to have a text box, enter the content, the automatic filtermaster dataSet. The Tables (" master "). The DefaultView. RowFilter="a Partnumber Like '%" & amp; TextBxSearch. Text & amp; "% '" found that the content of the text box can not filter,
If I don't show the master, the detail, when filling into datagirdview1 DataGridView1. The DataSource=dataSet. The Tables (" master "), the filter is very normal, study the days no see for a long time, why use the DataSource, datamember cannot filter,
The code is as follows:
Private Sub LoadData ()
Try
MyConnection=New System. The Data. The OleDb. OleDbConnection (" provider=Microsoft. ACE. The OleDb. 12.0; The Data Source=C: \ test. XLSX; Extended Properties=12.0 Excel;" )
DAmaster=New System. The Data. The OleDb. OleDbDataAdapter (" select a Partnumber, Option, the Description from [sheet1 $] where a Partnumber=Option ", MyConnection)
DAdetail=New System. The Data. The OleDb. OleDbDataAdapter (" select a Partnumber, Option, the Description from [sheet1 $] where partnumber<> The option, "MyConnection)
The dataSet=New System. The Data. The dataSet
DAmaster. The Fill (dataSet, "master")
DAdetail. The Fill (dataSet, "detail")
DataSet. Relations. The Add (" MasterDetail dataSet. The Tables (" Master "). The Columns (" a Partnumber "), and the dataSet. The Tables (" Detail "). The Columns (" a Partnumber "))
'DataGridView1. The DataSource=dataSet. The Tables (" master ")
DataGridView1. The DataSource=dataSet
DataGridView1. DataMember="master"
DataGridView2. The DataSource=dataSet
DataGridView2. DataMember="master. MasterDetail"
DataGridView1. Refresh ()
MyConnection. Close ()
Catch the ex As Exception
End the Try
End Sub
Private Sub TextBxSearch_TextChanged (sender As Object, As EventArgs e) Handles TextBxSearch. The TextChanged
The dataSet. The Tables (" master "). DefaultView. RowFilter="a Partnumber Like '%" & amp; TextBxSearch. Text & amp; "% '
"End Sub
End the Class