|
 |
|
.Net สอบถามเรื่อง การสั่งปริ้นจาก DataGridView C# หน่อยคับ |
|
 |
|
|
 |
 |
|
ผมคิดออกแต่วิธีโง่ๆอ่าครับ ถ้าคิดว่าพอใช้ได้นะครับ
Code (C#)
private void myDgv_main_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex != -1 && e.ColumnIndex != -1)
{
string temp = myDgv_main.Rows[e.RowIndex].Cells[0].Value.ToString();
string temp1 = myDgv_main.Rows[e.RowIndex].Cells[1].Value.ToString();
string temp2 = myDgv_main.Rows[e.RowIndex].Cells[2].Value.ToString();
}
}
เวลาคลิกที่ Gridview ก็ให้เก็บใส่ตัวแปรไว้ครับ(temp,temp1,temp2......) จากนั้นก็จะเอาไปสั่งปริ้นอะไรก็ได้ครับ
ไม่รู้ตรงกับความต้องการรึเปล่านะครับ ถ้าไม่เวิคก็ลองหาทางอื่นต่อดูนะครับ
|
ประวัติการแก้ไข 2013-05-18 19:58:23 2013-05-18 19:58:48
 |
 |
 |
 |
Date :
2013-05-16 21:49:52 |
By :
PizzaCPE23 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค๊ดผมแบบนี้คับ ต้องแก้ไงอ่ะคับ
Code (C#)
void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
// Print Header
e.Graphics.DrawString(" ---WIFI---", 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("", new Font("Arial", 16), Brushes.Black, 10, 100);
foreach (DataGridViewRow item in dataGridView1.Rows)
{
e.Graphics.DrawString((string)"username : " + item.Cells[0].Value, new Font("Arial", 12), Brushes.Black, 10, 80);
position += 20;
e.Graphics.DrawString((string)"password : " + item.Cells[1].Value, new Font("Arial", 12), Brushes.Black, 10, 150);
position += 20;
}
// Print Footer
e.Graphics.DrawLine(Pens.Gray, 10, 200, 830, 200);
e.Graphics.DrawString(" ขอบคุณครับ", new Font("Arial", 20), Brushes.Black, 10, 200);
}
|
 |
 |
 |
 |
Date :
2013-05-17 12:25:38 |
By :
goingmary |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|