System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument(); p.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(p_PrintPage); p.Print(); void p_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { foreach (Control item in groupBox1.Controls) { if (item is Label) { Label l = item as Label; e.Graphics.DrawString(l.Text, l.Font, new SolidBrush(l.ForeColor), l.Location); } } } 打印groupBox1上所有的label
System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();
p.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(p_PrintPage);
p.Print(); void p_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
foreach (Control item in groupBox1.Controls)
{
if (item is Label)
{
Label l = item as Label;
e.Graphics.DrawString(l.Text, l.Font, new SolidBrush(l.ForeColor), l.Location);
}
}
}
打印groupBox1上所有的label
打印demo,希望对你有帮助