我为大学创建了一个网络应用程序。我想在学生的打印结果中添加打印和打印预览按钮。哪些类用于打印表单?
我的打印和打印预览按钮编码如下:
protected void btnprint_Click(object sender, EventArgs e)
{
if (this.gridcontrol != null)
{
GridPrintDocument gpd = new GridPrintDocument(this.gridcontrol, true);
PrintDialog pritdlg = new PrintDialog();
pritdlg.Document = gpd;
if (pritdlg.ShowDialog() == DialogResult.OK)
gpd.Print();
}
else
{
lblstatus.Text="An error occurred attempting to print the grid ";
}
}
protected void btnprntprew_Click(object sender, EventArgs e)
{
if (this.gridcontrol != null)
{
//Uses the default printer.
GridPrintDocument gpd = new GridPrintDocument(this.gridcontrol, true);
PrintPreviewDialog pripredlg = new PrintPreviewDialog();
pripredlg.Document = gpd;
pripredlg.ShowDialog();
}
else
{
lblstatus.Text = "An error occurred attempting to preview the grid ";
}
}