我想将标题设置为我在Windows窗体中的PrintPreviewDialog中使用的文档。我尝试了一些东西,但是肯定这不是将TITLE设置为这种类型的文档的方法。你能帮帮我吗?
private void pd_print(object sender, PrintPageEventArgs e)
{
Graphics gr = e.Graphics;
gr.DrawString("Sales", new Font(FontFamily.GenericMonospace, 12, FontStyle.Bold), new SolidBrush(Color.Black), new Point(40, 40));
}
private void tiparireToolStripMenuItem_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_print);
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = pd;
dlg.ShowDialog();
}
答案 0 :(得分:0)
预览对话框只是一个隐藏Text属性的表单。
PrintPreviewDialog dlg = new PrintPreviewDialog();
((Form)dlg).Text = "My Title";
dlg.Document = pd;
dlg.ShowDialog();