All pastes #241369 Raw Edit

Untitled

public text v1 · immutable
·published 2006-11-06 03:08 UTC
rendered paste body
Public Class Form1

    Private Sub ToppingsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.ToppingsBindingSource.EndEdit()
        Me.ToppingsTableAdapter.Update(Me.PizzaDataSet.Toppings)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'PizzaDataSet.Menus' table. You can move, or remove it, as needed.
        Me.MenusTableAdapter.Fill(Me.PizzaDataSet.Menus)
        'TODO: This line of code loads data into the 'PizzaDataSet.Crusts' table. You can move, or remove it, as needed.
        Me.CrustsTableAdapter.Fill(Me.PizzaDataSet.Crusts)
        'TODO: This line of code loads data into the 'PizzaDataSet.Toppings' table. You can move, or remove it, as needed.
        Me.ToppingsTableAdapter.Fill(Me.PizzaDataSet.Toppings)
        'set the appearance and the flow direction of the FlowLayoutPanel
        Me.FlowLayoutPanel1.BorderStyle = BorderStyle.Fixed3D
        Me.FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown
        Me.FlowLayoutPanel2.BorderStyle = BorderStyle.Fixed3D
        Me.FlowLayoutPanel2.FlowDirection = FlowDirection.TopDown
        Me.FlowLayoutPanel3.BorderStyle = BorderStyle.Fixed3D
        Me.FlowLayoutPanel3.FlowDirection = FlowDirection.TopDown

        'define a datarow object to hold a record from Toppings table
        Dim row As PizzaDataSet.ToppingsRow
        'go through all the rows in the table
        For Each row In Me.PizzaDataSet.Toppings.Rows
            Dim chk As New CheckBox
            chk.Name = "CheckBox" & row.ToppingID
            chk.Text = row.ToppingName
            chk.AutoSize = True
            Me.FlowLayoutPanel1.Controls.Add(chk)
            AddHandler chk.CheckedChanged, AddressOf ToppingCheckChanged
        Next

        'define a datarow object to hold a record from Crusts table
        Dim row2 As PizzaDataSet.CrustsRow
        'go through all the rows in the table
        For Each row2 In Me.PizzaDataSet.Crusts.Rows
            Dim chk As New CheckBox
            chk.Name = "CheckBox" & row2.CrustID
            chk.Text = row2.CrustName
            chk.AutoSize = True
            Me.FlowLayoutPanel2.Controls.Add(chk)
            AddHandler chk.CheckedChanged, AddressOf CrustCheckChanged
        Next
        'define a datarow object to hold a record from Menu Items table
        Dim row3 As PizzaDataSet.MenusRow
        'go through all the rows in the table
        For Each row3 In Me.PizzaDataSet.Menus.Rows
            Dim chk As New CheckBox
            chk.Name = "CheckBox" & row3.MenuID
            chk.Text = row3.MenuName
            chk.AutoSize = True
            Me.FlowLayoutPanel3.Controls.Add(chk)
            AddHandler chk.CheckedChanged, AddressOf CrustCheckChanged
        Next
    End Sub

    Private Sub ToppingCheckChanged(ByVal sender As System.Object, ByVal e As EventArgs)
        Me.ListBox1.Items.Clear()  'clear the ListBox before updating
        For Each chkbox As CheckBox In Me.FlowLayoutPanel1.Controls
            If chkbox.Checked Then
                Me.ListBox1.Items.Add(chkbox.Text)
            End If
        Next
        Me.Label1.Text = "Number of toppings: " & Me.ListBox1.Items.Count.ToString()
    End Sub

    Private Sub CrustCheckChanged(ByVal sender As System.Object, ByVal e As EventArgs)
        Me.ListBox2.Items.Clear()  'clear the ListBox before updating
        For Each chkbox As CheckBox In Me.FlowLayoutPanel2.Controls
            If chkbox.Checked Then
                Me.ListBox2.Items.Add(chkbox.Text)
            End If
        Next
        Me.Label2.Text = "Number of toppings: " & Me.ListBox2.Items.Count.ToString()
    End Sub
End Class