How to print receipt in a picture box?

Hi,

I made a simple program that would generate a receipt preview, but I wander on how to do it in Visual Basic Express. I am going to use Picture Box because, other said that picture box can hold up a text or an image.

How can I do this with my example format below:


MyCompanyLogo
MyCompanyAddress


DATE: 05/06/2006 RCPT: 34566
STAFF: 23455 SND: 3467785667

1 480MLNSTEA ICE 18.00
2 SFGUAR SOAP 5.50

-------------------------------------------------------

TOTAL 23.50


CASH 25.00
CHANGE 1.50

VAT 0.00
VATable 0.00
VAT-Exempt sale 0.00


THIS SERVES AS OFFICIAL RECEIPT!

I want the format of a receipt like the above example:

Can u help me please:(



Answer this question

How to print receipt in a picture box?

  • Drew McCauley

    Use a RichTextBox Control(maybe you want to insert logos), loop through your data source, retrieve what is required to print line by line, and store them in the text box or in the string, also you can use CarriageReturn (i.e: vbcrlf) to go to a new line

    one point, i thought that the receipt preview you generated, and show it to us in the beginning of the thread, is a text, if it is, then use the same method to generate it in a text box

    good luck



  • software2

    Hi, i got the same problem, i am a beginner in VB 2005, i got the same problem then spotty

    i have develloped an application (getting information from our company database) for printing a facturation model, but i don't know how to print my form txt document.

    please help me.



  • SPersels

    Use the PrintDocument in the Printing namespace. This allows you to control printing, and use a printpreview control to view it on the screen. Lookup Printing.PrintDocument in help: the constructor link has a small example.

    Encapsulate the 'drawing' routine to draw/write to a graphics object, and you can draw your reciept to a picturebox, form, Usercontrol or printer.



  • Hoppe

    Hi, i got the same problem, i am a beginner in VB 2005, i got the same problem then spotty

    i have develloped an application (getting information from our company database) for printing a facturation model, but i don't know how to print my form as a txt document.

    please help me.



  • Jartai

    Thanks. I'm sure the development of my idea could be encapsulated into a UC. I might even if I get the time create it... Triss
  • Summerstreet

    I would use an IE box with formatted XML for this.

    I think there is much merit to Triss's suggestion. I don't know about XML but i just finished a large project which incorporates the WebBrowser control.

    http://www.onteorasoftware.net/downloads/renee.aspx

    It has things like print built in.

    You could easily internal format Html and graphics URLs (on your own disk).

    As you can see there are lots of ways to go but I really like the webbrowser control.



  • rocky_don

    It work!!!

    now i canprint what is in a textbox, but how to generate my invoice in a textbox



  • cmaclo

    CyberJunk!
    first generate the invoice in a text box, as formatted above, then use the following code to print what is inside a text box, look you can make the text box hidden or instead of using a textbox, you can use a string.

    *******************************************************************
    this was answered in thread RE:Print what is in text box

    one additional comment, printdocument will use the default installed printer on the system for printing, the method works like the following:
    (use the following steps and code to print what is inside the textbox only as you requested):

    first create a printdocument (named printdocument1) from the toolbox and place it on the form.
    second create controls on the form: textbox1 and button1.

    paste the following code:

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

    e.Graphics.DrawString(TextBox1.Text, TextBox1.Font, Brushes.Black, New System.Drawing.RectangleF(e.MarginBounds.Top, e.MarginBounds.Left, e.PageBounds.Width, e.PageBounds.Height))

    '* if you have many pages to print, then create a static counter to check after each page.

    e.HasMorePages = False

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    PrintDocument1.Print()

    End Sub

    *******************************************************************

    for a printing sample refer to:

    ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/dv_vbcodeexpress/html/d511f3be-c329-4ef0-8a9e-42783e611046.htm

    *******************************************************************



  • Silencer#1

    Nice idea and project ReneeC the "Renee's Knowledge Navigator"

    congratulations!



  • aLaMaT

    Hi,

    check out this url:
    http://weblogs.asp.net/mschiffer/archive/2004/07/13/181111.aspx

    This shows the code of a PrintForm replacement! This sample should be easily to be adapt to print only a PictureBox!

    Hope that helps!

    BavBoy


  • Nagendra Jammi

    hey, you could use a bit of Office Automation and send this to a word document. That way you could establish a nice template with all the company logo's etc. on and use this as the template for you receipt.

    Then you create the document via word object model to print it out. You dont show word during the process but get a lovely formatted document.

    You want to change the format of the receipt - new address/ different logo etc. then just change the word template file.


  • Raja Pratap Reddy

    Now that's pretty cool BavBoy
  • Jameslee20

    I would use an IE box with formatted XML for this.


  • N Adams

    You recieved poor information on this. I wouldb't use a picturebox. It will show text IF there is an image of text.

    For what your are doing, you could use either a text box or if you want to be somewhat more meticulous, a listview would look far better.



  • How to print receipt in a picture box?