|
![](/images/resource/spacer.gif) |
|
C# ปริ้นจาก DataGridView ไม่ได้ครับ มีรูปให้ดูครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
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);
}
![โปรแกรม โปรแกรม](https://www.thaicreate.com/upload/stock/20151009184036.png?v=1001)
![ไม่ผ่าน ไม่ผ่าน](https://www.thaicreate.com/upload/stock/20151009184051.png?v=1001)
Tag : .NET, Ms Access, C#
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-10-09 18:42:12 |
By :
pkraiya |
View :
1460 |
Reply :
3 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ตอบความคิดเห็นที่ : 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);
}
}
ไม่ได้เหมือนเดิมครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-10-10 14:03:13 |
By :
pkraiya |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (C#)
e.Graphics.DrawString(item.Cells[0].Value.ToString(), new Font("Arial", 10), Brushes.Black, 10, position);
14.position += 20;
ลองดูครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-10-10 19:43:17 |
By :
lamaka.tor |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 05
|