I am creating a program that make a person select different options and in other boxes it will populate the choice the person makes. Example is the program is fora car wash and if you choose standard or deluxe it will show in the other boxes what comes with that package.I got the program to work except when going to select a different option it still keeps the old info and displays the new info as well. I tried like at the bottom of the procedure Exteriorlist.Items.clear() and it would clear and never display the info. I am still working on the project I am trying to get the print option working properly I am just needing help in figuring out how to clear the info when I select a different package.

Public Class CarWash7

    Const EXTERIOR1_String As String = "Hand Wash"
    Const EXTERIOR2_String As String = "Hand Wax"
    Const EXTERIOR3_String As String = "Check Engine Fluids"
    Const EXTERIOR4_String As String = "Detail Engine Compartment"
    Const EXTERIOR5_String As String = "Detail Under Carriage"


    Const Interior1_String As String = "Fragrance"
    Const Interior2_String As String = "Shampoo Carpets"
    Const Interior3_String As String = "Interior Protecttion Coat"
    Const Interior4_String As String = "Shampoo Upholstery"
    Const Interior5_String As String = "Scotchgard"



    'Closes out the program.
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()

    End Sub
    'Clears All the boxes.
    Private Sub CleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CleToolStripMenuItem.Click
        'DetailPackageList.Items.Clear()
        Exteriorlist.Items.Clear()
        Interiorlist.Items.Clear()
        frangracecombolist.Items.Clear()

    End Sub

    Private Sub DetailPackageList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DetailPackageList.SelectedIndexChanged
        'Display the options in a Standard Detail Package
        If DetailPackageList.SelectedIndex = 0 Then
            Exteriorlist.Items.Add(EXTERIOR1_String)
            Interiorlist.Items.Add(Interior1_String)
            DetailPackageList.Items.Remove(Exteriorlist.Text)

            'Display the options in a Deluxe Detail Package
        ElseIf DetailPackageList.SelectedIndex = 1 Then
            Exteriorlist.Items.Add(EXTERIOR1_String)
            Exteriorlist.Items.Add(EXTERIOR2_String)
            Interiorlist.Items.Add(Interior1_String)
            Interiorlist.Items.Add(Interior2_String)
        End If


        'Display the options in a Executive Detail Package
        If DetailPackageList.SelectedIndex = 2 Then
            Exteriorlist.Items.Add(EXTERIOR1_String)
            Exteriorlist.Items.Add(EXTERIOR2_String)
            Exteriorlist.Items.Add(EXTERIOR3_String)
            Interiorlist.Items.Add(Interior1_String)
            Interiorlist.Items.Add(Interior2_String)
            Interiorlist.Items.Add(Interior3_String)
            'Display the options in a Luxury Detail Package
        ElseIf DetailPackageList.SelectedIndex = 3 Then
            Exteriorlist.Items.Add(EXTERIOR1_String)
            Exteriorlist.Items.Add(EXTERIOR2_String)
            Exteriorlist.Items.Add(EXTERIOR3_String)
            Exteriorlist.Items.Add(EXTERIOR4_String)
            Exteriorlist.Items.Add(EXTERIOR5_String)
            Interiorlist.Items.Add(Interior1_String)
            Interiorlist.Items.Add(Interior2_String)
            Interiorlist.Items.Add(Interior4_String)
            Interiorlist.Items.Add(Interior5_String)


        End If
        

    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
        'Set up the printer output
        Dim PrintFont As New Font("Arial", 12)
        Dim LineHeightSingle As Single = PrintFont.GetHeight + 2
        Dim VerticalPrintLocationSingle As Single = e.MarginBounds.Left
        Dim HorizontalPrintLocationSingle As Single = e.MarginBounds.Top
        Dim PrintLineString As String

        Using HeadingFont As New Font("Arial", 14)
            'Print Report Headings
            PrintLineString = "Very Busy Auto Center"
            e.Graphics.DrawString(PrintLineString, HeadingFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
            HorizontalPrintLocationSingle += LineHeightSingle
        End Using

        'Print the programmer's name
        PrintLineString = "Programmer: A. Programmer"
        e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
        HorizontalPrintLocationSingle += LineHeightSingle * 2
        'Print the exterior data
        PrintLineString = "Exterior: "
        e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
        HorizontalPrintLocationSingle += LineHeightSingle
        For ListIndexInteger As Integer = 0 To Exteriorlist.Items.Count - 1
            PrintLineString = Exteriorlist.Items(ListIndexInteger).ToString
            e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
            HorizontalPrintLocationSingle += LineHeightSingle
        Next ListIndexInteger
        HorizontalPrintLocationSingle += LineHeightSingle 'Blank line
    End Sub

 
End Class

Recommended Answers

All 2 Replies

If you haven't already figured this out, you need to copy lines 28 and 29 to just after line 34 so it clears the boxes before adding values. If this doesn't fix the problem, let me know.

What can you do if you need to add a dropdown menu to fragrance?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.