tags:

views:

39

answers:

1

I'm working on a C# / .net app. I want the user to be able to print preview, but I don't want the user to be able to print from the print straight from the preview dialog.

The print preview dialog has a little printer button on it that sends the previewed pages straight to the printer. Question is, is there a way to get rid of / disable / intercept this button click?

A: 

The PrintPreviewDialog class is actually a wrapper around the PrintPreviewControl class and it is what is supplying the buttons in the toolbar. Any form can host the PrintPreviewControl so what you would have to do is host the PrintPreviewControl in a dialog form you create:

public partial class PreviewDialog : Form
{
    public PreviewDialog() {
        this.printPreviewControl1 = new System.Windows.Forms.PrintPreviewControl();
        this.SuspendLayout();
        // 
        // printPreviewControl1
        // 
        this.printPreviewControl1.Dock = System.Windows.Forms.DockStyle.Fill;
        this.printPreviewControl1.Location = new System.Drawing.Point(0, 0);
        this.printPreviewControl1.Name = "printPreviewControl1";
        this.printPreviewControl1.Size = new System.Drawing.Size(292, 273);
        this.printPreviewControl1.TabIndex = 0;
        this.printPreviewControl1.Columns = 1;
        this.printPreviewControl1.Zoom = 1.0;
    }

}

The Columns property which is currently being set to 1 is the number of pages displayed by the control horizontally across the screen. The Zoom property sets the scale of the pages, 1.0 being full page; so < 1.0 would be a reduced image and > 1.0 would be an expanded image in the control per page. What you would want to do to the PreviewDialog class above is add a System.Windows.Forms.ToolStrip to it and then add buttons to handle the zoom, and pages per the properties mentioned (Columns and Zoom).

In the form that will bring the preview up (not the PreviewDialog form) you would have code like the following:

    private void buttonPrintPreview_Click(object sender, EventArgs e) {
        PreviewDialog dlg = new PreviewDialog();
        dlg.ShowDialog();
        return;
    }

Hopes this helps

Steve Ellinger
Seems like the right direction. Unfortunately, I don't at this point have the background to turn the above into working code.
Matthias Wandel