在打印按钮事件中添加以下代码
if (DevExpress.XtraPrinting.PrintHelper.IsPrintingAvailable)
{
PrintingSystem ps = new PrintingSystem();
PrintableComponentLink link = new PrintableComponentLink(ps);
link.Component = gc;
link.Landscape = true;
PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter;
phf.Header.Content.Clear();
phf.Header.Content.AddRange(new string[] { "", 站点信息表", "" });
phf.Header.Font = new System.Drawing.Font("宋体", 16, System.Drawing.FontStyle.Regular);
phf.Header.LineAlignment = BrickAlignment.Center;
phf.Footer.Content.Clear();
phf.Footer.Content.AddRange(new string[] { "", String.Format("打印时间: {0:g}", DateTime.Now), "" });
link.CreateDocument();
link.ShowPreview();
}
else
{
XtraMessageBox.Show("打印机不可用...", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}