I am working on Crystal Reports for Visual Studio 2005. I need to change the default printer, and the number of copies to 2 as compared to the default of 1.
I have succeeded to change the default printer using below code.
static int SetAsDefaultPrinter(string printerDevice)
{
int ret = 0;
try
{
string path = "win32_printer.DeviceId='" + printerDevice + "'";
using (ManagementObject printer = new ManagementObject(path))
{
ManagementBaseObject outParams =
printer.InvokeMethod("SetDefaultPrinter",
null, null);
ret = (int)(uint)outParams.Properties["ReturnValue"].Value;
}
}
}
How can I change the number of copies printed?
.Net Framework doesn't provide any mechanism to override the default print functionality. So I disabled the default print button, and added a button name Print.Code for the Event Handler follows below.