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.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 '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 Next 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 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 End Class