我正在写一个应用程序,需要打印来自DataGridView的一些信息,我已经有了我想打印的字符串,我只是不知道如何。我在网上发现了一些东西,说我需要使用PrintDocument对象和PrintDialog。如何用打印机打印字符串?
让我们假设我有3个字符串,我想在一行(第1,2和3行)中打印每一个字符串,但第一个字符必须以粗体显示并使用Arial字体。 输出(纸张)将是:
string 1 (in bold and using the Arial font)
string 2
string 3
编辑:(由abelenky问)
验证码:
private void PrintCoupon()
{
string text = "Coupon\n";
foreach (DataGridViewRow dgvRow in dataGridViewCarrinho.Rows)
{
foreach (DataGridViewCell dgvCell in dgvRow.Cells)
{
text += dgvCell.Value.ToString() + " ";
}
text += "\n";
}
MessageBox.Show(text);
// I should print the coupon here
}
所以我怎么做,使用C#?
谢谢。
向我们展示你的码。 – abelenky 2013-05-12 00:28:42
@abelenky有代码,完整的源代码在390行以上。但那是我打印字符串的部分。 – Zignd 2013-05-12 00:40:43
是的,你需要使用printdocument,我解释了在我的回答中,你是否尝试过? – Mehran 2013-05-12 00:43:13