Hi,
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 conn As SqlConnection
Dim strConn As String
Dim strCmd As String
Dim da, daProducts As SqlDataAdapter
Dim strServer As String = "(local)"
strConn = String.Format("Server = {0};", strServer)
strConn &= "Database = Northwind; Integrated Security = sspi;"
conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * From Categories", conn)
da.Fill(ds, "Categories")
daProducts = New SqlDataAdapter("Select * from Products", conn)
daProducts.Fill(ds, "Products")
dv = New DataView(ds.Tables("Products"))
With cmbCategories
..DataSource = ds.Tables("Categories")
..DisplayMember = "CategoryName"
..ValueMember = "CategoryID"
End With
With cmbProducts
..DataSource = dv
..DisplayMember = "ProductName"
End With
End Sub
Private Sub cmbCategories_SelectedValueChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles cmbCategories.SelectedValueChanged
Try
dv.RowFilter = "CategoryID = " & cmbCategories.SelectedValue.ToString
Catch
End Try
End Sub
Ken
------------------------------
"pmcguire" <pm******@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
Hmm. I don't really understand.
You mean use a filtered DataView as the second ComboBox's DataSource? I am
already doing that. The problem isn't obtaining the list of values needed
for the ComboBox, the problem is that I want to bind the SelectedValue of
the
two ComboBoxes to columns in another table. When PositionChanged fires,
Combo1 and Combo2 both get new values; however, in general, the value Combo2
gets from its currency manager is not yet present in its list, so after
Combo1_SelectionIndexChanged fires (somewhat later) and Combo2 synchs up,
the
BindingContext interprets Combo2 as having modified the record.
Forgive me if I'm being dense, but does your solution solve this? And if
so, could you show me an example of how to do what you are describing?
Thanks,
Pat
"Ken Tucker [MVP]" wrote:
Hi,
Bind the second combobox to a dataview. Use the
dataview.rowfilter
method to only show the right records.
Ken
---------------
"pmcguire" <pm******@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.com...
I have 2 bound ComboBoxes. I want the datasource of the second to be
limited
by the selection made in the first. I can do this by responding to the
SelectionIndexChanged event on the first, but this results in the
BindingContext's Current.Row.Rowstate becoming 'Modified' whenever the
BindingContext position changes. What is the RIGHT way to go about this?
Thanks,
--
Pat