Option Strict On

Public Class Form1

    Dim dcNordwind As New NordwindEntities



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.ValueMember = "OrderID"
        ComboBox1.DisplayMember = "OrderID"

        ComboBox1.DataSource = dcNordwind.Orders
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        Dim odAktuelleBestellung As Orders = CType(ComboBox1.SelectedItem, Orders)
        Dim intOrderID As Integer = odAktuelleBestellung.OrderID

        Dim quBestellDetails = From Bestelldetails In dcNordwind.Order_Details _
                               Join Produkte In dcNordwind.Products _
                               On Bestelldetails.ProductID Equals Produkte.ProductID _
                                Where Bestelldetails.OrderID = intOrderID _
                                Select New With {Bestelldetails.OrderID, Produkte.ProductName, Bestelldetails.Quantity, Produkte.UnitPrice}
        DataGridView1.DataSource = quBestellDetails
    End Sub


    Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        dcNordwind.SaveChanges()
    End Sub
End Class
