Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling "print" button in .net print preview dialog

Tags:

c#

.net

printing

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?

like image 992
Matthias Wandel Avatar asked Sep 22 '10 19:09

Matthias Wandel


1 Answers

You can access the print button, and any other button from a print preview control by searching in the container's controls collection.

For the print button:

(ToolStripButton)((ToolStrip)printPreviewDialog1.Controls[1]).Items[0]

so, to disable it,

((ToolStripButton)((ToolStrip)printPreviewDialog1.Controls[1]).Items[0]).Enabled = false;
like image 135
Ion Roata Avatar answered Sep 28 '22 04:09

Ion Roata