|
|
|
C# ปริ้นจาก DataGridView ไม่ได้ครับ มีรูปให้ดูครับ |
|
|
|
|
|
|
|
Code (C#)
private void btnPrint_Click(object sender, EventArgs e)
{
PrintDialog printDialog = new PrintDialog();
printDialog.Document = printDocument1;
printDialog.UseEXDialog = true;
//Get the document
if (DialogResult.OK == printDialog.ShowDialog())
{
printDocument1.DocumentName = "Test Page Print";
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
// Print Header
e.Graphics.DrawString("Header Report Title", new Font("Arial", 20), Brushes.Black, 10, 10);
e.Graphics.DrawLine(Pens.Gray, 10, 50, 830, 50);
// Print content
int position = 130;
e.Graphics.DrawString("-- Data from Data Grid View --", new Font("Arial", 16), Brushes.Black, 10, 100);
foreach (DataGridViewRow item in dataGridSearch.Rows)
{
e.Graphics.DrawString((string)item.Cells[0].Value, new Font("Arial", 10), Brushes.Black, 10, position);
position += 20;
}
// Print Footer
e.Graphics.DrawLine(Pens.Gray, 10, 1050, 830, 1050);
e.Graphics.DrawString("Footer Report Title", new Font("Arial", 20), Brushes.Black, 10, 1060);
}
Tag : .NET, Ms Access, C#
|
|
|
|
|
|
Date :
2015-10-09 18:42:12 |
By :
pkraiya |
View :
1449 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 1 เขียนโดย : mr.win เมื่อวันที่ 2015-10-09 22:26:32
รายละเอียดของการตอบ ::
Code (C#)
private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
{
// Print Header
e.Graphics.DrawString("Header Report Title", new Font("Arial", 20), Brushes.Black, 10, 10);
e.Graphics.DrawLine(Pens.Gray, 10, 50, 830, 50);
// Print content
int position = 130;
e.Graphics.DrawString("-- Data from Data Grid View --", new Font("Arial", 16), Brushes.Black, 10, 100);
foreach (DataGridViewRow item in dataGridSearch.Rows)
{
e.Graphics.DrawString((string)item.Cells[0].Value.ToString(), new Font("Arial", 10), Brushes.Black, 10, position);
position += 20;
}
// Print Footer
e.Graphics.DrawLine(Pens.Gray, 10, 1050, 830, 1050);
e.Graphics.DrawString("Footer Report Title", new Font("Arial", 20), Brushes.Black, 10, 1060);
}
}
ไม่ได้เหมือนเดิมครับ
|
|
|
|
|
Date :
2015-10-10 14:03:13 |
By :
pkraiya |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
e.Graphics.DrawString(item.Cells[0].Value.ToString(), new Font("Arial", 10), Brushes.Black, 10, position);
14.position += 20;
ลองดูครับ
|
|
|
|
|
Date :
2015-10-10 19:43:17 |
By :
lamaka.tor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|