private void button2_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count == 0) { MessageBox.Show("请先导入数据!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //先测试下预览 //一英寸=2.54厘米,这里是百分之一英寸,目前的纸张是长12厘米,宽9厘米354,472 this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", 354, 472); //这个是标签纸张大小 this.printDocument1.PrintPage += new PrintPageEventHandler(this.my_print); printPreviewDialog1.Document = printDocument1; DialogResult result = printPreviewDialog1.ShowDialog(); }
每次预览都显示旧的数据,导致显示重叠,该怎么样解决
解决方案
30
那就每次打印,printDocument1重新new一下
10
PrintPreviewDialog.Document.Dispose()