locked
How to print the bill in a billing system made in VB.Net ? RRS feed

  • Question

  • Hi, I am making a billing system and I am totally stuck in getting a print of bill receipt.

    Right now the selected product, its rate, cost and quantity appears on the datagridview1 and when the user clicks on generate bill the data of the gridviewexports to the rich text box in the right with all other details but the data on the textbox is not aligned properly and also when I created the print function for the text in textbox it can only be done with one font and I want multiple fonts But if I can get a solution of printing the datagridview with the logo and some labels in a panel so the problem of rich text box would be automatically solved. Thanks in advanced to all those who will reply.


    • Edited by Manit Vig Thursday, January 3, 2019 10:30 AM
    Thursday, January 3, 2019 10:27 AM

All replies

  • Hello,

    I would recommend another approach, use ReportViewer which requires more work. With a ReportViewer you display a preview before printing.

    Using the report viewer you design the report (which equates to what you have in the DataGridView) with desired fonts and formatting then provide a print button which optionally provides print preview or not.

    For the runtime version of ReportViewer, open NuGet Package manager in Visual Studio, once open paste in

    Install-Package Microsoft.ReportViewer.Windows -Version 11.0.3452

    To get an idea how to work with ReportViewer see the following page which shows both VB.NET and C#.

    In closing, anyone who never used ReportViewer before will need time to get up to speed with it and this is a much better way to go then working with a rich textbox control as mentioned above, ReportViewer is template based with no need to manipulate RichText. The RichText control uses under the covers RTF codes and that is a very difficult thing to manipulate in regards to changing the font and other attributes. 



    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, January 3, 2019 10:52 AM
  • I think I'm not clear about my question or program if I could just get to know How I can export datagridview data to a rich text box like a table with proper alignment and print the text in the rich text box with different fonts but one document? I will get my problem solved
    Friday, January 4, 2019 4:42 AM
  • Hi,

    see the link,I hope it can help you.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/8a2ebbe7-0f9b-4bbd-bcc0-ed5b7fc2c319/how-to-print-richtextbox-with-muliple-font-size-and-color?forum=vbgeneral

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 7, 2019 3:06 AM