Hi,
Create a dataview to for the datagrid. Bind the datagrid to the
dataview. Filter the records in the combobox selected item changed event.
Dim ds As New DataSet
Dim dv As DataView
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String
Dim strSQL As String
Dim da, daOrders As OleDbDataAdapter
Dim conn As OleDbConnection
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"
conn = New OleDbConnection(strConn)
da = New OleDbDataAdapter("Select * From Customers", conn)
da.Fill(ds, "Customers")
daOrders = New OleDbDataAdapter("Select * From Orders", conn)
daOrders.Fill(ds, "Orders")
dv = New DataView(ds.Tables("Orders"))
ComboBox1.DataSource = ds.Tables("Customers")
ComboBox1.DisplayMember = "CustomerID"
DataGrid1.DataSource = dv
End Sub
Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedValueChanged
Dim drv As DataRowView
Try
drv = DirectCast(ComboBox1.SelectedItem, DataRowView)
dv.RowFilter = "CustomerID = '" & drv.Item("CustomerID").ToString & "'"
Catch ex As Exception
End Try
End Sub
Ken
----------------------
"Larry Woods" <la***@NOSPAMlwoods.com> wrote in message
news:uy*************@TK2MSFTNGP11.phx.gbl...
I have a combobox that is populated with a list of names. When a name is
selected I want to populate a datagrid with name information. I have my
master-detail defined in my dataset and it works fine if I use a datagrid
for the master, instead of a combobox. But the combobox won't cause the
repopulation of the datagrid with the appropriate data. What's the trick?
TIA,
Larry Woods
cross-posted on ...dotnet.languages.vb.controls