2 Replies - 6228 Views - Last Post: 06 December 2010 - 08:53 AM Rate Topic: -----

#1 kieran82   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 22-November 10

Printing all content in a windows form

Posted 05 December 2010 - 04:12 PM

I have all my project finished and have know idea how to do this. I have to get the program to print the invoice and have all the code done in the form but not the print button. i have the printdialog1 and PrintDocument1 on my form and can't get any further. can anyone help.here is the code i have so far in my invoice form.

Imports System
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Windows.Forms

Public Class frmIrishInvoiceForm

Private Sub btnDisplayDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayDetails.Click
        lblDate.Text = Now 'Show Current Date in Date Label Box 
        lblCustomerName.Text = strCustomerName 'Show Customer Name in Customer Name label box 
        lblStreetAddress.Text = strStreet 'Show Street in Street label Box
        lblTownCity.Text = strTown_City 'Show TownCity in TownCity label Box
        lblCounty.Text = strCounty 'Show County in TownCity label Box
        lblCountry.Text = strCounty 'Show TownCity in County label Box
        lblPostalCode.Text = strPostalCode 'Show postal Code in postal Code label Box
        lblTelephone.Text = strArea_Code & "  -  " & strTelephoneNo 'Show Area Code and Telephone No in Telephone label Box
        lblArrivalDate.Text = DateArrive 'Show DateArrival in ArrivalDate label Box
        lblDepartureDate.Text = DateLeave 'Show Dateleave in DepartureDate label Box
        lblNoOfDaysStay.Text = intNoOfDaysStay 'Show NoOfDaysStay in NoOfDaysStay label Box
        lblPassportNo.Text = strPassportNo 'Show PassportNo in PassportNo label Box
        lblNoOfDaysTreatment.Text = intNoOfTreatmentsStay 'Show No Of Days for Treatments in NoOfDaysTreatment label Box
        lblPaymentMethod.Text = strPaymentMethod

        'If Finance package is displayed in the Payment Selection
        If strPaymentSelection = "Finance Package" Then
            pnlFinancePackage.Visible = True
            lblNoOfYears.Text = intRepaymentYears
            lblRepayments.Text = FormatNumber(decRepayments, 2)
            lblLoanPayments.Text = strLoan_Type
            strPaymentMethod = "Finance Package"
        Else
            'Else Credit Card is displayed in the Payment Selection
            pnlCreditCard.Visible = True
            lblCardType.Text = strCredit_Debit_Type
            lblCreditDebitCardNo.Text = strCredit_Debit_No
            lblExpiryDate.Text = strExpiry_Month & " / " & strExpiry_Year
            strPaymentMethod = "Credit Card"
        End If

        'Add Grand Total to Overall Total
        decOverallTotalEuro += decGrandTotalEuroPrice
        decOverallTotalIrish += decGrandTotalIrishPrice

        'Format label Box To Currency
        lblTotalPrice.Text = FormatNumber(decGrandTotalEuroPrice, 2)
        lblIrishPrice.Text = FormatNumber(decGrandTotalIrishPrice, 2)
        'Get savings by dividing Total irish price by Total Euro price 
        decTotalPercentSavings = decGrandTotalEuroPrice / decGrandTotalIrishPrice
        lblSavings.Text = FormatPercent(decTotalPercentSavings)
    End Sub
    'Exit Button
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        End 'Close Program
    End Sub
    'Print Menu Button
    Private Sub mnuPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrint.Click
        btnPrintForm_Click(sender, e)
    End Sub
    'About Menu Button
    Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
        frmAboutUs.Show() 'Show About Form
    End Sub
    'Display Details Menu Button
    Private Sub mnuDisplayDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisplayDetails.Click
        btnDisplayDetails_Click(sender, e)
    End Sub

    'Exit Menu Button
    Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
        End ' Exits The Program
    End Sub

    Private Sub btnPrintForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintForm.Click
      

    End Sub
    'New Customer
    Private Sub btnNewCustomer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewCustomer.Click

        decGrandTotalEuroPrice = 0
        decGrandTotalIrishPrice = 0


        strCustomerName = ""
        strStreet = ""
        strTown_City = ""
        strCounty = ""
        strCountry = ""
        strPostalCode = ""
        strArea_Code = ""
        strTelephoneNo = ""
        strPassportNo = ""
        decPrincipal = 0
        intRepaymentYears = 0
        decRepayments = 0
        strLoan_Type = ""
        strCredit_Debit_No = ""
        strCredit_Debit_Type = ""
        strCV2_No = ""
        strExpiry_Month = ""
        strExpiry_Year = ""

        Me.Close()
        frmCustomerDetails.Show()

        frmIrishTreatment.btnReset_Click(sender, e)
        frmUKTreatments.btnReset_Click(sender, e)
        frmCustomerDetails.cleartextboxes()
    End Sub
    'Summary Renu Item
    Private Sub mnuSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSummary.Click
        frmSummaryForm.Show()
    End Sub
    'Summary Button
    Private Sub btnSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSummary.Click
        frmSummaryForm.Show()
    End Sub
End Class





Is This A Good Question/Topic? 0
  • +

Replies To: Printing all content in a windows form

#2 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Printing all content in a windows form

Posted 05 December 2010 - 07:09 PM

You use the PrintPage event of the PrintDocument when you call the .Print method. In this event you draw much like you use GDI+.

Print Document

You can draw rectangles, images(like a logo), text, ellipsis, etc...
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Printing all content in a windows form

Posted 06 December 2010 - 08:53 AM

I know that wasn't the answer you were looking for, but you need to realize we do not spoon-feed code here. If you give a reasonable attempt you will find much help here. Voting a post down will get you less and less - make sense.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1