none
Printout is not what I expected RRS feed

  • Question

  • I need some help with the following problem.

    I have made a simple pos system that will let the user push buttons that represent the menu items and those items show up on the reciept. I am using formatting zones to line up the items. This part of the program works fine and the display on the screen keeps everything lined up.

    My data is contained inside of a sorted list and my objects come from a menuitem class

    the properties are :

    name - holds the name of the menuitem

    price- holds the price

    cost - holds price * Quantity

    Quantity - how many

    key - so each entry into the sorted list is unique

     The name of my sorted list is itemcoll And my theory is that i can loop through the sorted list and print each element until reaching the end of the list.

    The problem is that when I try to print out the reciepts the

    zones no longer line up the way they do on my computer screen. Here is the code I am using.

    'Print page code

    private sub CashierRecieptDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles CashierRecieptDocument.PrintPage  

    'Variable for y coordinate of the text

    Dim ycoord As Integer = 90

    Dim s As String  = " "

    'font for text

    Dim DrawMenuItem As New Font("Microsoft courier new", 12)

    'Display Ticket Number

    e.graphics.DrawString(txtTicketNumber.Text, DrawMenuItem, Brushes.Black, 50, 50)

    'Display menu items

    For i As Integer = 0 to itemcoll.Count - 1

          s = String.Format("{0,3}  {1,-14}  {2,7:C}", itemcoll.Values(i).Quantity, itemcoll.Values(i).name, itemcoll.Values(i).Cost)

    e.Graphics.DrawString(s, DrawMenuItem, Brushes.Black, 1, ycoord)

    yc += 18

    next

    end sub

    On my computer screen the display looks like this:

     1       ER             $3.99

     2       CK FR       $7.99

    19      Cokes       $8.99

    On my Reciept after printing looks like:

     1    ER  $3.99

      2    CK FR    $7.99

    19   Cokes   $8.99

    I tried to show that zones do not line up straight like the reciept does on the screen.

    Am i using the right formatting technique or is there another one that is more appropiate.

    I have been writing this program for eight months and I think I have read all the post regarding printing but I still am having this problem.

    Any help would be appreciated

     

                               

     

    Tuesday, December 5, 2006 3:38 PM

Answers

  • It is interesting that this is not printing correctly after applying the string.format with your formatters.   It might be just as easy to print each item on the X coord seperately.   So instead of putting them all into one string  you could do an e.graphics.DrawString() for each column just increasing the X value for each one and then reset it back for the next row.
    Wednesday, December 6, 2006 5:17 AM

All replies

  • It is interesting that this is not printing correctly after applying the string.format with your formatters.   It might be just as easy to print each item on the X coord seperately.   So instead of putting them all into one string  you could do an e.graphics.DrawString() for each column just increasing the X value for each one and then reset it back for the next row.
    Wednesday, December 6, 2006 5:17 AM
  • Thank You for your input, this is the first time i have used a forum and I did not know if this would work or not.

    I had to leave my computer at work tonight but i will try  this first thing in the morning and i will let you know how it goes, it sounds like it will work.

    Wednesday, December 6, 2006 7:04 AM
  • Thank You again for your help , it worked and it makes sense to me too.

     

    Thursday, December 7, 2006 4:26 PM