我只需要在打印预览后重置“边框”。我预览了我想正确打印的页面,但是当我打印时它给出了空白页,因为“边框”没有重置。我应该把“border=0”放在哪里?(“border”是没有。datagridview中的行)
private void button5_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = pd;
ppd.ShowDialog();
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
prntt(sender, e);
}
public void prntt(object sender, PrintPageEventArgs e)
{
for (; border < ViewA.RowCount; border++)
{
if (ustsin + yuk > e.MarginBounds.Bottom - 400f)
{
e.HasMorePages = true;
return;
}
texts = ViewA.Rows[border].Cells["Persons"].Value.ToString();
...
graphics.DrawString(texts, font, Brushes.Black, new RectangleF(e.MarginBounds.Left, ustsin, 115f, 90f));
...
float hoho = (float)e.Graphics.MeasureString(texts, font, 115, StringFormat.GenericTypographic).Height;
...
var mesele = new float[] { hoho, koko, moko };
float kapa = mesele.OrderByDescending(s => s).First();
ustsin += kapa + yuk;
}
e.HasMorePages = false;
}
如果在打印预览中按下打印按钮时我可以关闭,我可以在其关闭事件中重置吗?
编辑:我这样做了,它似乎可以工作,但是当我将它发送到 xps 时,它在屏幕上显示 2 页。像这样http://i.imgur.com/a9KnkA0.png。我怎样才能让这个节目只有 1 页?
private void printDocument1_EndPrint(object sender, PrintEventArgs e)
{
border = 0;
}