更新时间:2023-02-21 17:07:01
您有几个属性可供使用,例如:
You have several properties to use, like:
With PrintDialog1
.AllowCurrentPage = True;
.AllowSomePages = True;
.AllowPrintToFile = True;
.AllowSelection = True;
.ShowDialog();
End With
更多关于:
PrintDialog类 [ ^ ]
PrintDialog Properties [ ^ ]
AllowCurrentPage [ ^ ]
AllowSomePages [ ^ ]
好的,现在我得到了,你想要的。
请看下面的例子:
More about:
PrintDialog Class[^]
PrintDialog Properties[^]
AllowCurrentPage[^]
AllowSomePages[^]
OK, now i''m getting, what you want.
Please, see below example:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public int numcopies = 0;
public int currcopy = 0;
public string[] strCopy = new string[] {"ORIGINAL COPY", "DUPLICATE COPY","TRIPLICATE COPY","QUADRUPLICATE COPY"};
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//print document
System.Drawing.Printing.PrintDocument pdoc = new System.Drawing.Printing.PrintDocument();
pdoc.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 830, 1070);
pdoc.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 830, 1070); ;
//add event handler
pdoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pdoc_PrintPage);
DialogResult res = DialogResult.Cancel;
System.Windows.Forms.PrintDialog pdlg = new PrintDialog();
pdlg.AllowCurrentPage = true;
pdlg.AllowPrintToFile = true;
pdlg.Document = pdoc;
res = pdlg.ShowDialog();
if (res == DialogResult.OK)
{
//ignore number of copies set by user; number of copies if const ;)
numcopies = 4;
};
//print 4 copies
for (int i = 1; i<numcopies+1 ;i++ )
{
currcopy = i-1;
pdoc.DocumentName = strCopy[currcopy].ToString();
pdoc.Print();
}
}
// The PrintPage event is raised for each page to be printed.
private void pdoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(strCopy[currcopy ].ToString(), new Font("Arial", 9, FontStyle.Underline), Brushes.Black, 350, 30);
e.Graphics.DrawString(this.textBox1.Text, new Font("Arial", 10, FontStyle.Italic), Brushes.Black, 30, 30);
e.Graphics.DrawString(this.textBox2.Text, new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 400, 70);
e.Graphics.DrawString(this.textBox3.Text, new Font("Arial", 9), Brushes.Black, new Rectangle(390, 100, 370, 50));
e.Graphics.DrawString(this.textBox4.Text, new Font("Arial", 9), Brushes.Black, 490, 160);
}
}
}
我希望这是你想要的; )
[/ EDIT]
提示/提示:
添加4个复选框的自定义对话框(窗体)会很棒:
- oryginal
- 1.复制
- 2.复制
- 3.复制
取决于用户选择,程序应该只打印选定的副本。
[/ EDIT]
I hope this is what you want ;)
[/EDIT]
Tip/Hint:
It would be great to add custom dialogbox (windows form) with 4 checkboxes:
- oryginal
- 1. copy
- 2. copy
- 3. copy
Depends on user selection, program should print only selected copies.
[/EDIT]