Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hai Experts


I want to print a 'Lab bill" Form that the user has filled out without having to create a report. I am new to Windows Apps, (mostly famliar with Asp.net).
My code is given bellow
1) this code in a button click


ControlPrint mp = new ControlPrint(panel1);
           mp.PrintWidth = mp.CalculateSize().Width;
           mp.PrintHeight = mp.CalculateSize().Height;
        PrintDialog PrintDialog1 = new PrintDialog();

           System.Drawing.Printing.PrintDocument docToPrint =
              new System.Drawing.Printing.PrintDocument();

           PrintDialog1.AllowSomePages = true;


           PrintDialog1.ShowHelp = true;

           PrintDialog1.Document = docToPrint;

           DialogResult result = PrintDialog1.ShowDialog();


           if (result == DialogResult.OK)
           {
               docToPrint.Print();
           }


2)
public void StartPrint(Stream streamToPrint, string streamType)
        {
            this.printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);

            this.streamToPrint = streamToPrint;
            this.streamType = streamType;
            System.Windows.Forms.PrintDialog PrintDialog1 = new PrintDialog();
            PrintDialog1.AllowSomePages = true;
            PrintDialog1.ShowHelp = true;
            PrintDialog1.Document = printDocument1;

            DialogResult result = PrintDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {

                printDocument1.Print();

            }

        }

but I tried this example and only get a blank page out of the printer
what is the problem in my code and please help me
i give a thanks in advance
Posted
Updated 28-Dec-11 22:35pm
v2

You can use
visual basic powerpacks printform component to print a form.

or

you can use printdocument class
 
Share this answer
 
Here[^] are some suggestions and articles.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900