简体   繁体   中英

How to show Print preview in form control?

I can't figure out how to show print preview in control.

I have class Printer : PrintDocument that contains what I want to print but how to show that in form and in which control.


tried this and it works in windows forms application but I need something for WPF application. Here I used PrintPreviewControl but I don't know how to show it in WPF form. Also I would prefer to use DocumentViewer to show preview. Can anyone help me with that?

     PrintPreviewControl ppc;
     //Here goes MouseDown I just used btn_Click for testing
     private void btnClick_Click(object sender, EventArgs e)
     {
         Printer p = new Printer();
         ppc = new PrintPreviewControl();
         ppc.Document = p;
         ppc.Location = new Point(10, 50);
         ppc.Width = 700;
         ppc.Height = 1000;
         ppc.Name = "PPC";

         this.Controls.Add(ppc);
     }

Should be something like this:

var printDialog = new PrintPreviewDialog();

printDialog.Document = new Printer();
printDialog.ShowDialog();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM