|
![](/images/resource/spacer.gif) |
|
มีปัญหากับการใช้ PadRight ในการสร้างฟอร์มเอกสาร ตำแหน่งของตัวอักษรไม่เท่ากัน |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (C#)
Graphics graphic = e.Graphics;
Font font = new Font("Angsana New", 12);
float fontHeight = font.GetHeight();
int startX = 10;
int startY = 10;
int offset = 135;
graphic.DrawString(" ร้านวัฒนวณิชย์", new Font("Angsana New", 17), new SolidBrush(Color.Black), startX, startY);
graphic.DrawString(" 110 หมู่ที่ 1 ต.บ้านแพ้ว อ.บ้านแพ้ว", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY + 30);
graphic.DrawString(" จังหวัด สมุทรสาคร 74120", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY + 50);
graphic.DrawString(" Tel.034-481-253", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY+70);
graphic.DrawString(" สินค้า จำนวน ราคา", new Font("Angsana New", 12), new SolidBrush(Color.Black), startX, startY+110);
graphic.DrawString("----------------------------------------------------", new Font("Angsana New", 15), new SolidBrush(Color.Black), startX, startY+120);
while (sqlite_datareader.Read())
{
string product = (sqlite_datareader.GetString(4) + " " + sqlite_datareader.GetString(5) + " (" + sqlite_datareader.GetString(6)+")").PadRight(40);
int princ = sqlite_datareader.GetInt32(14);
string productLine = product+ "1 " + String.Format("{0:c}", princ);
graphic.DrawString(productLine, font, new SolidBrush(Color.Black), startX, startY + offset);
offset = offset + (int)fontHeight + 5;
}
offset = offset + 15;
graphic.DrawString(" ราคารวม " + totalprice + " บาท", new Font("Angsana New", 14), new SolidBrush(Color.Black), startX, startY + offset);
}
ด้านบนเป็น Code ของผมที่ต้องการสร้างฟอร์มเอกสารใบเสร็จขึ้นมาครับ โดยตัวลายละเอียดสินค้านั้น จะให้โชว์ ชื่อสินค้า จำนวน และก็ราคา โดยที่เว้นระยะห่างเท่าๆกันครับ เลยใช้คำสั่ง PadRight(40) ลงไป แต่ก็ออกมาดั่งที่เห็น
![หน้าตาเอกสารที่ได้ หน้าตาเอกสารที่ได้](https://www.thaicreate.com/upload/stock/20180917181330.png?v=1001)
ผมพลาดตรงไหนไปรึเปล่าครับ รบกวนแนะนำด้วยครับ
ขอบคุณครับ
Tag : Report Others, Win (Windows App), C#, Windows
![](/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 :
2018-09-17 18:14:45 |
By :
zlzca71013 |
View :
854 |
Reply :
1 |
|
![](/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) |
|
ใช้ Justify content
|
![](/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 :
2020-08-01 14:26:19 |
By :
PhrayaDev |
|
![](/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 00
|