投稿者 魔界の仮面弁士  (社会人) 投稿日時 2019/8/23 01:30:12
> ところがその後、DataGridViewが更新されません。
> DataSetビジュアライザーを覗くと、"クエリ1"は更新されていますのに。

実際のコードを見てみない事には何とも言えませんが、おそらくそれは、
両者が見ている DataTable が、それぞれ別のインスタンスなのだと思います。


話を単純化するために、単一のフォームで説明しますが、
たとえば下記を実行すると、ComboBox1 と ComboBox2 が選択しているアイテムは
それぞれ連動するのに対し、ComboBox3 は連動していないことがわかります。


Private Sub Form1_Load(ByVal sender As ObjectByVal e As EventArgs) Handles MyBase.Load
    Dim ds As New DataSet()
    Dim tbl As DataTable = ds.Tables.Add("TBL")
    tbl.Columns.Add("Key"GetType(Integer))
    tbl.Columns.Add("Value"GetType(String))
    tbl.PrimaryKey = New DataColumn() {tbl.Columns("Key")}
    tbl.Rows.Add(100, "AAA")
    tbl.Rows.Add(200, "BBB")
    tbl.Rows.Add(300, "CCC")
    tbl.Rows.Add(400, "DDD")
    tbl.AcceptChanges()

    ComboBox1.DisplayMember = "Value"
    ComboBox2.DisplayMember = "Value"
    ComboBox3.DisplayMember = "Value"

    ComboBox1.ValueMember = "Key"
    ComboBox2.ValueMember = "Key"
    ComboBox3.ValueMember = "Key"

    '1 と 2 は同じインスタンスを見ているが 
    '3 は別のインスタンスを参照している 
    ComboBox1.DataSource = tbl
    ComboBox2.DataSource = tbl
    ComboBox3.DataSource = tbl.Copy()
End Sub

Private Sub ComboBoxes_SelectionChangeCommitted(ByVal sender As ObjectByVal e As EventArgs) Handles ComboBox1.SelectionChangeCommitted, ComboBox2.SelectionChangeCommitted, ComboBox3.SelectionChangeCommitted
    Label1.Text = "SelectedIndex"
    Label2.Text = "SelectedValue"
    Label3.Text = "Text"
    Label4.Text = "GetItemText()"
    For Each cb As ComboBox In New ComboBox() {ComboBox1, ComboBox2, ComboBox3}
        Label1.Text &= ", [" & CStr(cb.SelectedIndex) & "]"
        Label2.Text &= ", [" & CStr(cb.SelectedValue) & "]"
        Label3.Text &= ", [" & cb.Text & "]"
        Label4.Text &= ", [" & cb.GetItemText(cb.SelectedItem) & "]"
    Next
End Sub