1,105,328 Community Members

Combo boxes and Printing

Member Avatar
Purrenhage
Newbie Poster
10 posts since Nov 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I am trying to get this Program to print. Most of it is working correctly except for the part of the Fragrance. When it prints it is printing the whole list not what I selected. The exterior and interior are printing correctly and I tried to set the combo box up the same way. I did the debugging and I can see it loop thru the printing process over and over to get all the names in my list. I just don’t see why it is doing it or how to stop it.

Public Class CarWash7
    'Declaring the Exteroir constants
    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"

    'Declaring interior constants
    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"

    Const Frangrance1_string As String = "Hawaiian Mist"
    Const Frangrance2_string As String = "Baby Powder"
    Const Frangrance3_string As String = "Pine"
    Const Frangrance4_string As String = "Country Floral"
    Const Frangrance5_string As String = "Pina Colada"
    Const Frangrance6_string As String = "Vanilla"




    '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()
    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

            'Clears the boxes
            Exteriorlist.Items.Clear()
            Interiorlist.Items.Clear()

            'lists the package options
            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

            'Clears the boxes
            Exteriorlist.Items.Clear()
            Interiorlist.Items.Clear()

            'lists the package options
            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

            'Clears the boxes
            Exteriorlist.Items.Clear()
            Interiorlist.Items.Clear()

            'lists the package options
            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 Luxruy Detail Package
        ElseIf DetailPackageList.SelectedIndex = 3 Then

            'Clears the boxes
            Exteriorlist.Items.Clear()
            Interiorlist.Items.Clear()

            'lists the package options
            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 frangracecombolist_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles frangracecombolist.SelectedIndexChanged



        If frangracecombolist.SelectedIndex = 1 Then

            'Clears the boxes
            frangracecombolist.Items.Clear()

            'lists the package options
            frangracecombolist.Items.Add(Frangrance1_string)

            'Display the options in a Deluxe Detail Package
        ElseIf frangracecombolist.SelectedIndex = 2 Then

            'lists the package options
            frangracecombolist.Items.Add(Frangrance2_string)

        End If

        If frangracecombolist.SelectedIndex = 3 Then

            'Clears the boxes
            frangracecombolist.Items.Clear()

            'lists the package options
            frangracecombolist.Items.Add(Frangrance3_string)

            'Display the options in a Deluxe Detail Package
        ElseIf frangracecombolist.SelectedIndex = 4 Then

            'lists the package options
            frangracecombolist.Items.Add(Frangrance4_string)

        End If

        If frangracecombolist.SelectedIndex = 5 Then

            'Clears the boxes
            frangracecombolist.Items.Clear()

            'lists the package options
            frangracecombolist.Items.Add(Frangrance5_string)

            'Display the options in a Deluxe Detail Package
        ElseIf frangracecombolist.SelectedIndex = 6 Then

            'lists the package options
            frangracecombolist.Items.Add(Frangrance6_string)

        End If


    End Sub

    Private Sub PrintDocument1_PrintPage_1(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        If DetailPackageList.SelectedIndex = -1 Then
            MessageBox.Show("Please choice a package")
        End If

        If frangracecombolist.SelectedIndex = -1 Then
            MessageBox.Show("Please choice a Frangrace")
        End If
        '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:Scott Purrenhage"
        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 



        'Printing the interior data
        PrintLineString = "Interior: "
        e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
        HorizontalPrintLocationSingle += LineHeightSingle
        For ListIndexInteger As Integer = 0 To Interiorlist.Items.Count - 1
            PrintLineString = Interiorlist.Items(ListIndexInteger).ToString
            e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
            HorizontalPrintLocationSingle += LineHeightSingle
        Next ListIndexInteger
        HorizontalPrintLocationSingle += LineHeightSingle 'Blank line 




        'Printing the Fragrance data
        PrintLineString = "Fragrance Selected: "
        e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
        HorizontalPrintLocationSingle += LineHeightSingle
        For ListIndexInteger As Integer = 0 To frangracecombolist.Items.Count - 1
            PrintLineString = frangracecombolist.Items(ListIndexInteger).ToString
            e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, VerticalPrintLocationSingle, HorizontalPrintLocationSingle)
            HorizontalPrintLocationSingle += LineHeightSingle
        Next ListIndexInteger
        HorizontalPrintLocationSingle += LineHeightSingle 'Blank line 

    End Sub

    Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
        'called the printdocument
        PrintDocument1.Print()

    End Sub

End Class
Member Avatar
lolafuertes
Posting Shark
912 posts since Oct 2008
Reputation Points: 145 [?]
Q&As Helped to Solve: 196 [?]
Skill Endorsements: 7 [?]
 
0
 

Please be so kind to describe the goal of your

Private Sub frangracecombolist_SelectedIndexChanged

and where you fill this fragancecombolist before the SelectedIndexChange event is fired.

Thanks in advance

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: